From patchwork Tue Jun 26 15:10:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sameeh Jubran X-Patchwork-Id: 10489301 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D84D460386 for ; Tue, 26 Jun 2018 15:12:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD05927F88 for ; Tue, 26 Jun 2018 15:12:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39B6128334; Tue, 26 Jun 2018 15:12:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 040D92841D for ; Tue, 26 Jun 2018 15:11:57 +0000 (UTC) Received: from localhost ([::1]:53256 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXpdM-0004an-O8 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 26 Jun 2018 11:11:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXpcK-0003lP-71 for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:10:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXpcI-00089h-0N for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:10:52 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:34899) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fXpcH-00089U-Pg for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:10:49 -0400 Received: by mail-wm0-x242.google.com with SMTP id z137-v6so2266299wmc.0 for ; Tue, 26 Jun 2018 08:10:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references:list-id; bh=ZVaOzqfyhhX8JKzKWx9VG/TC/Y2N7teO00dnPfYCNkQ=; b=iKOk4swN4yiJbbECYXyg5RBKDckjTZ56T3dWr0H3WM3XBmRGcOPlXHJ24H3JKcx1b5 qrOKzKovP1/8Y1PTKvlNhZnVanRQuoUbu93OeeY/X/J18Ahj1+GRPyUcNhKmL9fTPohA FhvF4R9k+f7KEiGkxByPfhstTcAAGZHHTr4BNwuOCRqf65jZTglLEiUClaN1rQ6lnKnI iCnAWMNbuYV9hjqRYN8vKxcmBzibMuaXtMwmrC03Fh1eJgjK8/32cwpr0yrQoDjxw4S6 /BpwPvVrMIutGeWt1wY51fuq1GY8e3NHxly6iPs5ZJA9xlmt4oHPtR2Imrnlka7DD3qO wSJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:list-id; bh=ZVaOzqfyhhX8JKzKWx9VG/TC/Y2N7teO00dnPfYCNkQ=; b=ffR6sALGpFhZkOXAyvjhnuDlhU6pBTir7VpwNG8DtwWAiNOXabVY94hzJzcUvyUY0E 7DTAgq/w8yr0DIvxyv+XF5JzRKf0IOkgPvuO72IzwdDAw/1jr74JoQYxMmFXec+6RvTy kIhdYPBsUVI5zxUJZPxmszj63N81xteuw+UvZcHDl9Pam6h0bbIMaerHBDi/TVhfy0aY NgQEI9sUcEaA2snITL2hXWx2GjRwWxR1xX2qOGClgrZFYMKjhrlk6Gd4x2rdFD4uvWtS dxVOYoRf0u1rIxGB6RnaXbfRSi4TwZ0KJ/ZJPMZVsOXl/9WByDD6vraZ/9Lhxj0XJNX3 BFBQ== X-Gm-Message-State: APt69E1kcNdbbeRDHTP9WBpNLveBb6CZ0gXPJnJqAR+6CzcR1ayHASXL 56CPpkTlCIiGPxr88jbRlsiCNvF6 X-Google-Smtp-Source: AAOMgpcsNEY1su1ngOpp4KdyG01HbZFfm9E8/8Vs+NXStxYCnIKSV2K/0rKygeOejBYchKejmCrBBA== X-Received: by 2002:a1c:d287:: with SMTP id j129-v6mr1869944wmg.106.1530025848732; Tue, 26 Jun 2018 08:10:48 -0700 (PDT) Received: from bark.daynix ([141.226.163.173]) by smtp.gmail.com with ESMTPSA id w15-v6sm2503195wrn.25.2018.06.26.08.10.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jun 2018 08:10:47 -0700 (PDT) From: Sameeh Jubran To: qemu-devel@nongnu.org Date: Tue, 26 Jun 2018 18:10:37 +0300 Message-Id: <20180626151038.24771-2-sameeh@daynix.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180626151038.24771-1-sameeh@daynix.com> References: <20180626151038.24771-1-sameeh@daynix.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PATCH 1/2] qga-win: prevent crash when executing fsinfo command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yan Vugenfirer , Michael Roth Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Sameeh Jubran The fsinfo command is currently implemented for Windows only and it's disk parameter can be enabled by adding the define "CONFIG_QGA_NTDDSCSI" to the qga code. When enabled and executed the qemu-ga crashed with the following message: ------------------------------------------------ File qapi/qapi-visit-core.c, Line 49 Expression: !(v->type & VISITOR_OUTPUT) || *obj) ------------------------------------------------ After some digging, turns out that the GuestPCIAddress is null and the qapi visitor doesn't like that, so we can always allocate it instead and initiate all it's members to -1. Signed-off-by: Sameeh Jubran Reviewed-by: Philippe Mathieu-Daudé --- qga/commands-win32.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 2d48394748..c5f1c884e1 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -485,6 +485,11 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp) char *buffer = NULL; GuestPCIAddress *pci = NULL; char *name = g_strdup(&guid[4]); + pci = g_malloc0(sizeof(*pci)); + pci->domain = -1; + pci->slot = -1; + pci->function = -1; + pci->bus = -1; if (!QueryDosDevice(name, dev_name, ARRAY_SIZE(dev_name))) { error_setg_win32(errp, GetLastError(), "failed to get dos device name"); @@ -556,7 +561,6 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp) func = addr & 0x0000FFFF; dev = (addr >> 16) & 0x0000FFFF; - pci = g_malloc0(sizeof(*pci)); pci->domain = dev; pci->slot = slot; pci->function = func;