From nobody Wed Nov 5 10:37:12 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153363931162238.48753432358376; Tue, 7 Aug 2018 03:55:11 -0700 (PDT) Received: from localhost ([::1]:38347 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmzdu-0004Fs-HH for importer@patchew.org; Tue, 07 Aug 2018 06:55:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmzag-00026U-8M for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:51:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmzab-0004Iq-Ct for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:51:50 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39252) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fmzab-0004IT-5m for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:51:45 -0400 Received: by mail-wr1-f66.google.com with SMTP id h10-v6so15309382wre.6 for ; Tue, 07 Aug 2018 03:51:45 -0700 (PDT) Received: from fiorina.brq.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id j9-v6sm1287794wrv.5.2018.08.07.03.51.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Aug 2018 03:51:43 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=X5LepDNieYkbdKjEhwiYO8WZOnC/U4KooY5hzpI0S2k=; b=hMISbUiwx6gG+zURkLE+pgssrw+a09N4llnDIYoXMlm52sp64S2UejetdSnA5bcSrB /awcxTC+235db0euUEdskZfi/nIUw6tRyXU7OaxtG4T/IRyzbOltpUqqQIbR+tflVqBj M8z2gUQ8QVXj6UXi3K0AaykgL0lLdkLq4cdqlyWssexhg/fmP+iWYsDmQ5cGYoM5qu3y EysE3gC0xeQJXhPkD1g8imAgqTgk8Q9rJ8pKENBOninRhbujyBb3jvHleMOfh8qazVKy CXOZ8FoAbyAk0ENNFdgyJLThD3bsPGp2JYnb3JhrHB0+/6nQsCFtDsDdoN6Dt6Pi/8QZ jXQg== X-Gm-Message-State: AOUpUlFtRBJq6+TmOtWwUzGniij2KxsjSCv+IvpZiprfgZjz3259WOOG WnXD/iAeoWQN3zE0pmWR22szIuEtWLo= X-Google-Smtp-Source: AAOMgpcluze3YJfbhR84Zd7unnk8AJ1wNWFFjtu5+MeCYBvvAalBGDUYlv1d1tM4i7GuuZLqhVCEdw== X-Received: by 2002:a5d:6748:: with SMTP id l8-v6mr12473273wrw.197.1533639103950; Tue, 07 Aug 2018 03:51:43 -0700 (PDT) From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= To: qemu-devel@nongnu.org Date: Tue, 7 Aug 2018 12:51:37 +0200 Message-Id: <951d1c8265e9ef6b36d61358fd01f267a9b83ca7.1533639095.git.tgolembi@redhat.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.221.66 Subject: [Qemu-devel] [PATCH v2 3/4] qga: win32: fix crashes when PCI info cannot be retrived 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Michael Roth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 The guest-get-fsinfo command collects also information about PCI controller where the disk is attached. When this fails for some reasons it tries to return just the partial information. However in certain cases the pointer to the structure was not initialized and was set to NULL. This breaks the serializer and lead to crasehs of the guest agent. Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD --- qga/commands-win32.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 36d76c22c0..995f62c2e4 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -642,15 +642,32 @@ static GuestDiskAddressList *build_guest_disk_info(ch= ar *guid, Error **errp) g_debug("getting pci-controller info"); if (DeviceIoControl(vol_h, IOCTL_SCSI_GET_ADDRESS, NULL, 0, scsi_a= d, sizeof(SCSI_ADDRESS), &len, NULL)) { + Error *local_err =3D NULL; disk->unit =3D addr.Lun; disk->target =3D addr.TargetId; disk->bus =3D addr.PathId; - disk->pci_controller =3D get_pci_info(name, errp); + g_debug("unit=3D%lld target=3D%lld bus=3D%lld", + disk->unit, disk->target, disk->bus); + disk->pci_controller =3D get_pci_info(name, &local_err); + + if (local_err) { + slog("failed to get PCI controller info: %s", + error_get_pretty(local_err)); + error_free(local_err); + } else if (disk->pci_controller !=3D NULL) { + g_debug("pci: domain=3D%lld bus=3D%lld slot=3D%lld functio= n=3D%lld", + disk->pci_controller->domain, + disk->pci_controller->bus, + disk->pci_controller->slot, + disk->pci_controller->function); + } } - /* We do not set error in this case, because we still have enough - * information about volume. */ - } else { - disk->pci_controller =3D NULL; + } + /* We do not set error in case pci_controller is NULL, because we still + * have enough information about volume. */ + if (disk->pci_controller =3D=3D NULL) { + g_debug("no PCI controller info"); + disk->pci_controller =3D g_malloc0(sizeof(GuestPCIAddress)); } =20 list =3D g_malloc0(sizeof(*list)); --=20 2.18.0