From nobody Mon Feb 9 13:07:19 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1639394290; cv=none; d=zohomail.com; s=zohoarc; b=fdGu60I3pq5vuLTsz3enAiPOD7XzllZWs61jE17hkX0YKBszerETrgtRZo0blLmZ0ZdwlmCbvsOwbYVi639S4eUu41lnC0pi10Yp0ed2xSCO7rZPXeUu6qQBPeaB2ghhoKxnLEbgo5Lwlzs8e9aiRyQwCQL9Hvtixxr9UnLn1Fg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639394290; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UOq7HXf+K8oMudzzz7NHQ+jQVflm2qA+bj7AzU+PASI=; b=PXUPrLbJuC4mHslYefXj0y4WA+EY1n4nb8p5vHWHmHLVD+xEZqXzgsykgCO1t5u/E9UBegD3UAsiQq8Zex4HlqGPibWAY4azKNaYJMCOO417yJuWMN/SWm3cqnOnjAJBWtxVByiaCNhzmAMA/0c1bOqkhLTEjz0x5rXHcgaxIBY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1639394290771987.9710043242392; Mon, 13 Dec 2021 03:18:10 -0800 (PST) Received: from localhost ([::1]:33934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mwjLN-0002ZX-JA for importer@patchew.org; Mon, 13 Dec 2021 06:18:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47518) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mwjJU-0008Vz-CP for qemu-devel@nongnu.org; Mon, 13 Dec 2021 06:16:12 -0500 Received: from [2a00:1450:4864:20::52a] (port=42715 helo=mail-ed1-x52a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mwjJS-0007FV-Ea for qemu-devel@nongnu.org; Mon, 13 Dec 2021 06:16:12 -0500 Received: by mail-ed1-x52a.google.com with SMTP id r11so50238159edd.9 for ; Mon, 13 Dec 2021 03:16:07 -0800 (PST) Received: from kostyanf14nb.Dlink ([37.72.42.118]) by smtp.gmail.com with ESMTPSA id a13sm6139384edk.29.2021.12.13.03.16.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 03:16:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=UOq7HXf+K8oMudzzz7NHQ+jQVflm2qA+bj7AzU+PASI=; b=sFtXHZJzIKgcGpBwUs+JNSib1s5iRrXfkAAAcRX+NSJx1hC4sjDYBaL2J92hoqkFAa xXke3SZH4C5ZvTyJF6OnLIctlTgo3IK/OGyVMLIX+/MA2Kb4nDSJKUVb5gmY4STRG4zY HbOBNzz25cETmGAaEgJFhr/hyXLfEp1y3hnKoGe3bBdDX4bnPWqYir0Pdh6iyzjWGsDs QVpJNm2vniDOktf62G5lr2xq85iYLnTi3TYWLNwomimi65M0PIdfYsRwxkEI+4g8XKUH wL+WzLCPIaviMxgn2FVD12RiyX3BVtqxeHgdbKSoWUxj2In++uIEA+KsrmSdaVURNlda 4PLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UOq7HXf+K8oMudzzz7NHQ+jQVflm2qA+bj7AzU+PASI=; b=HGzYVdz467bpAsWo92EOtbpXq5MQQl+6JzN4i8CXfv8JIqKs8cpH+6NEMr7/c1wsQ7 k3hVeK1i7SjHuelocZe8jyMja/9/cC0DJqOneS2gp1Er2AlQ/kySHdxb2prPfqoaspTj KVjBDqL3xJQwqVcQVquzN5OilDz3N2Dh2L8hRxF+Q8rPxTRf5sMJcaILhRk2P6nykk/S 83WtLHPFGKnN0fGGjCUb/s36wHurhYUKhP2LVU83qiUJS1LSAjKUGgS5ZmVog1LAfgbh I5c8hZwuNK9tYiY+7m1avDYDFu5iGy0rk/jGAjJTBp/faBZB/HfZEqv5GfTOg18DkYc9 VuuA== X-Gm-Message-State: AOAM531DwZx5uOU5PGhQei3IAiOinvryLHnpHPrmfP3+CvPhHU9Xwbri /CJEQOMag7hf0oi7aXpLfr+hP6mgxZ734g== X-Google-Smtp-Source: ABdhPJxPWDn1mFyH8gk3X7PBRa9eGUFEI04KngwIWTauWTcOlrA0foHSD+6GS+9ziK5jYsbnzB3dzw== X-Received: by 2002:a50:c35b:: with SMTP id q27mr63056301edb.154.1639394166451; Mon, 13 Dec 2021 03:16:06 -0800 (PST) From: Kostiantyn Kostiuk To: qemu-devel@nongnu.org, Michael Roth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 1/5] gqa-win: get_pci_info: Clean dev_info if handle is valid Date: Mon, 13 Dec 2021 13:15:50 +0200 Message-Id: <20211213111554.62394-2-konstantin@daynix.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211213111554.62394-1-konstantin@daynix.com> References: <20211213111554.62394-1-konstantin@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::52a (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::52a; envelope-from=konstantin@daynix.com; helo=mail-ed1-x52a.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1639394292155100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kostiantyn Kostiuk Signed-off-by: Kostiantyn Kostiuk Reviewed-by: Marc-Andr=C3=A9 Lureau --- qga/commands-win32.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 4e84afd83b..3dd74fe225 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -514,7 +514,7 @@ DEFINE_GUID(GUID_DEVINTERFACE_STORAGEPORT, static GuestPCIAddress *get_pci_info(int number, Error **errp) { - HDEVINFO dev_info; + HDEVINFO dev_info =3D INVALID_HANDLE_VALUE; SP_DEVINFO_DATA dev_info_data; SP_DEVICE_INTERFACE_DATA dev_iface_data; HANDLE dev_file; @@ -749,7 +749,9 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) } free_dev_info: - SetupDiDestroyDeviceInfoList(dev_info); + if (dev_info !=3D INVALID_HANDLE_VALUE) { + SetupDiDestroyDeviceInfoList(dev_info); + } out: return pci; } -- 2.25.1 From nobody Mon Feb 9 13:07:19 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1639394291; cv=none; d=zohomail.com; s=zohoarc; b=DgpIELdrD5HS67SJ9ortVJ6HY2rufBm9hHpPG6Isdm9m44qjRXBY+UWRqlhqP3UPBHejr61h2GeU5cNsX5WJcVMbIhBnzAV/EjSvT7eEaEkWyoTDqka4ND8JlZKOMTVqHh16pxv6G+nCHZx/XbeHiZnHTX3mTSDQ9aFISn4yO7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639394291; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mMxX3If9fTUUjGK3dbCE2gziT93rl8rcCI1gT1hsj0o=; b=LLiDslaR6jGcuuus0jDmYUp6KMY+zLUx+xQZIYg44JdVSNsvbd5NjlB8FV3fX6IQuMJgX0NVj7SbaixmBQFx/6ZqCbf4QJJ6d5VzpkOu03FS52Ik1ibuMO8vrex0x5XcSYbOCWN0BXz7TuFmF4u2b53CGewc18vpHocwT6lzofg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1639394291048544.4932001678666; Mon, 13 Dec 2021 03:18:11 -0800 (PST) Received: from localhost ([::1]:34088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mwjLN-0002fq-VC for importer@patchew.org; Mon, 13 Dec 2021 06:18:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mwjJW-0008WH-3R for qemu-devel@nongnu.org; Mon, 13 Dec 2021 06:16:15 -0500 Received: from [2a00:1450:4864:20::52f] (port=42720 helo=mail-ed1-x52f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mwjJS-0007Ff-GX for qemu-devel@nongnu.org; Mon, 13 Dec 2021 06:16:13 -0500 Received: by mail-ed1-x52f.google.com with SMTP id r11so50238316edd.9 for ; Mon, 13 Dec 2021 03:16:08 -0800 (PST) Received: from kostyanf14nb.Dlink ([37.72.42.118]) by smtp.gmail.com with ESMTPSA id a13sm6139384edk.29.2021.12.13.03.16.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 03:16:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=mMxX3If9fTUUjGK3dbCE2gziT93rl8rcCI1gT1hsj0o=; b=YQWbPTzWjE/zhrhyUcnkrVQdmcrZ0XeL29Q5wJ/szVWPVWhccKtUzbhXCKA5fmu5Q1 bShuIH5YHZUGp4ORLntd9kA++NDiuw1hlC9GEwXA+o+IjCyN2BazeodWeQPPFzZMqd2R cd2kuM4eQMYna3hPAxCD+M5uJa0QEaLic++65hUreuV0gahubY0cbRqODVfz5NsJ8sYG grTetEXkQK2frk07iplg2Pkn5OFejb/NUuOgABntT6YIHTPF9btHJr5WQleJL2dMGUA/ HuSzKdlu4ucISTCJ7VvJPbSbi75MrZLq2H8eYpTCw1kgNzVdh7y7Ij0PcCU+0tNiswZh deaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mMxX3If9fTUUjGK3dbCE2gziT93rl8rcCI1gT1hsj0o=; b=o+P0w99D3EDDuNTQU2RXHfg+Kk8/81VxlF9G5btW1TIhpy8NAyhbnOpjElOMx4PIrX gEtD1VprBgEIgvJb+PBdVGaI7IA+94SF7aMD4B55T4np1AeEmuBFFLnjkPNSrQc5zDnI kQ9lTfcRQlAg4jPPbFuXwhZGTOzscvR61B58WDBIC1AAruM6qzElLFl1FZXW8hwJK9Mo Mwm2d+JYSUDf+tau8ZljkmeT1Ghi5BCwESfBtj2OSDrkACb8Yi5p1e036QuYHOtsU2NF bWeF4d4z2FpdZhTZwFs3KTFcaSAdk6rkvCPCW/q6K15gvqTA1Du36Zhs4nMHVsnRiso6 aUng== X-Gm-Message-State: AOAM530rL0C0QGEeccFOrFA8j1g0Exw7/0ogW9SHU2Xy9VeiKD++3WaW s+bTBCNkvTXdEIw5h+6m1HHQ5nbAb9bblw== X-Google-Smtp-Source: ABdhPJzkiw/Kj1mO0Ffiu8824fNwt0vSYsmnoZCdrsVW5JU+7WHPKrctN0886VdcwYVrNApw9OUgZQ== X-Received: by 2002:a05:6402:5206:: with SMTP id s6mr64355859edd.286.1639394167356; Mon, 13 Dec 2021 03:16:07 -0800 (PST) From: Kostiantyn Kostiuk To: qemu-devel@nongnu.org, Michael Roth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 2/5] gqa-win: get_pci_info: Use common 'cleanup' label Date: Mon, 13 Dec 2021 13:15:51 +0200 Message-Id: <20211213111554.62394-3-konstantin@daynix.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211213111554.62394-1-konstantin@daynix.com> References: <20211213111554.62394-1-konstantin@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::52f (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::52f; envelope-from=konstantin@daynix.com; helo=mail-ed1-x52f.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1639394292199100005 Content-Type: text/plain; charset="utf-8" To prevent memory leaks, always try to free initialized variables. Signed-off-by: Kostiantyn Kostiuk Signed-off-by: Kostiantyn Kostiuk Reviewed-by: Marc-Andr=C3=A9 Lureau --- qga/commands-win32.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 3dd74fe225..12f7a88078 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -532,7 +532,7 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); if (dev_info =3D=3D INVALID_HANDLE_VALUE) { error_setg_win32(errp, GetLastError(), "failed to get devices tree= "); - goto out; + goto cleanup; } g_debug("enumerating devices"); @@ -562,7 +562,7 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) } else { error_setg_win32(errp, GetLastError(), "failed to get device interfaces"); - goto free_dev_info; + goto cleanup; } } @@ -576,7 +576,7 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) CloseHandle(dev_file); error_setg_win32(errp, GetLastError(), "failed to get device slot number"); - goto free_dev_info; + goto cleanup; } CloseHandle(dev_file); @@ -586,7 +586,7 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) } else { error_setg_win32(errp, GetLastError(), "failed to get device interfaces"); - goto free_dev_info; + goto cleanup; } g_debug("found device slot %d. Getting storage controller", number= ); @@ -603,7 +603,7 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) } else { error_setg_win32(errp, GetLastError(), "failed to get device instance ID"); - goto out; + goto cleanup; } } @@ -617,14 +617,14 @@ static GuestPCIAddress *get_pci_info(int number, Erro= r **errp) g_error("CM_Locate_DevInst failed with code %lx", cr); error_setg_win32(errp, GetLastError(), "failed to get device instance"); - goto out; + goto cleanup; } cr =3D CM_Get_Parent(&parent_dev_inst, dev_inst, 0); if (cr !=3D CR_SUCCESS) { g_error("CM_Get_Parent failed with code %lx", cr); error_setg_win32(errp, GetLastError(), "failed to get parent device instance"); - goto out; + goto cleanup; } cr =3D CM_Get_Device_ID_Size(&dev_id_size, parent_dev_inst, 0); @@ -632,7 +632,7 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) g_error("CM_Get_Device_ID_Size failed with code %lx", cr); error_setg_win32(errp, GetLastError(), "failed to get parent device ID length"); - goto out; + goto cleanup; } ++dev_id_size; @@ -647,7 +647,7 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) g_error("CM_Get_Device_ID failed with code %lx", cr); error_setg_win32(errp, GetLastError(), "failed to get parent device ID"); - goto out; + goto cleanup; } } @@ -661,14 +661,14 @@ static GuestPCIAddress *get_pci_info(int number, Erro= r **errp) if (parent_dev_info =3D=3D INVALID_HANDLE_VALUE) { error_setg_win32(errp, GetLastError(), "failed to get parent device"); - goto out; + goto cleanup; } parent_dev_info_data.cbSize =3D sizeof(SP_DEVINFO_DATA); if (!SetupDiEnumDeviceInfo(parent_dev_info, 0, &parent_dev_info_da= ta)) { error_setg_win32(errp, GetLastError(), "failed to get parent device data"); - goto out; + goto cleanup; } for (j =3D 0; @@ -748,11 +748,10 @@ static GuestPCIAddress *get_pci_info(int number, Erro= r **errp) break; } -free_dev_info: +cleanup: if (dev_info !=3D INVALID_HANDLE_VALUE) { SetupDiDestroyDeviceInfoList(dev_info); } -out: return pci; } -- 2.25.1 From nobody Mon Feb 9 13:07:19 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1639394290; cv=none; d=zohomail.com; s=zohoarc; b=IATT7JzHlksRFVHD6Q8rPOBRx0CL+EQ6meHGMhWGTOhrLWo4HAXe3JH5Ag/kOIlvd4PaOX6dESVlkdLKMV5gYPVBMtjpkVC5X2ATI8Kv0OR3dTxBz+/+vQ0rK5G8Qzgyj4MW+GT1afUdV9NN3VNBvwYaGbWmN3K8uxkaHefFFcA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639394290; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZyjWKDKqH2alTErU781Viw3hW4bS53yAycPis4lhQRk=; b=ITRB2xZi7pZvrg0RzMtAL4Sj2DMKjJF2+NB9txakUUoiPCxqN3qUhtIkUX1jeenTyoH15NolE4zh4flG6QLHcpfSLtTdMGNV1m6ct7fZ/GEQZgI8i3jJ2diFMd/jTNub/6tynYN8CT79Mur44A+HxbEtzpKxqSZRnw1eFo+ucyA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163939429069324.603682468931652; Mon, 13 Dec 2021 03:18:10 -0800 (PST) Received: from localhost ([::1]:33924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mwjLN-0002ZG-8F for importer@patchew.org; Mon, 13 Dec 2021 06:18:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mwjJU-0008W0-HN for qemu-devel@nongnu.org; Mon, 13 Dec 2021 06:16:12 -0500 Received: from [2a00:1450:4864:20::52a] (port=35574 helo=mail-ed1-x52a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mwjJS-0007Fl-GY for qemu-devel@nongnu.org; Mon, 13 Dec 2021 06:16:12 -0500 Received: by mail-ed1-x52a.google.com with SMTP id v1so51262934edx.2 for ; Mon, 13 Dec 2021 03:16:09 -0800 (PST) Received: from kostyanf14nb.Dlink ([37.72.42.118]) by smtp.gmail.com with ESMTPSA id a13sm6139384edk.29.2021.12.13.03.16.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 03:16:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ZyjWKDKqH2alTErU781Viw3hW4bS53yAycPis4lhQRk=; b=wyu3kJG6fWDQX1PeUxnjK2xOP5Cttq05VZCASbif9/HeTqb8imyw9LueiingxDy+vX hsA2PtnKKFBKHG7TFOA436UqLRi3UIp/CcIhceZRa1Q+oli1S7wrhxLcavUt8/xEpwIN 3FlgEEKVjLxElcDYPs0OJ0FsWVy0x/jHW16bSWKUXKhrV2QW/OQ0iWJY2eWpPlYECWmx gpoZVEYaRKxl420NI9YHxfnYa47EqivMipZNPN6zHBnJAwmLenM7neBkT6tfFIZ0koG6 AW2pQSuFnvZ46XZGUSaxSAjqfyQoWlYmw+BBXZsHje+rATOvsbR9EfwQMDiQN8lAj3lu X1WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZyjWKDKqH2alTErU781Viw3hW4bS53yAycPis4lhQRk=; b=7dWbgSEkvSq722H2DzNsn07Kb1lfTa3rTkmrX0Mdy6FpaSmUzulziylX+coGJHi2de tSFLLRX2DAFNWLwxreC+NZEWsDWPBy0QZy7Rhzm56HRmQ57t3srzT1hngjwt+zUP+z68 zKaCHtB8quTcjcymCrD+rowG+zocpxUjeGT2pLsG1kLEWTJkQYPkJn4F8X7T+Z2SC1uz 6Er9sXnEw4lPOeHxZOjaK+NFdI0zECgtoohTQqtS/Zx4sBR6ybKx4vtV1QNhbnWWIx9+ j/Ikd6tfoFom+bdHKAODQ1CPU1DqryV+5/P2026FGwwbjATp7nt9luIztOQLrtjyn37p aOYw== X-Gm-Message-State: AOAM531cWg4tE6a6bfqnKfC5JicGxoxmzVjvMCUNCVRzWvEwcCZgrxsV MjPgtqiS/80F8pgZtJH1rWbeFJdqAkXWTw== X-Google-Smtp-Source: ABdhPJzoft/rmap85EooIh5zWWrRDafibkeMhEYz/XPWAydZ7+PoY4niLLim2T+StAV/GUyKdlcycw== X-Received: by 2002:aa7:db47:: with SMTP id n7mr63959186edt.303.1639394168294; Mon, 13 Dec 2021 03:16:08 -0800 (PST) From: Kostiantyn Kostiuk To: qemu-devel@nongnu.org, Michael Roth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 3/5] gqa-win: get_pci_info: Free parent_dev_info properly Date: Mon, 13 Dec 2021 13:15:52 +0200 Message-Id: <20211213111554.62394-4-konstantin@daynix.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211213111554.62394-1-konstantin@daynix.com> References: <20211213111554.62394-1-konstantin@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::52a (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::52a; envelope-from=konstantin@daynix.com; helo=mail-ed1-x52a.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1639394292122100001 Content-Type: text/plain; charset="utf-8" In case when the function fails to get parent device data, the parent_dev_info variable will be initialized, but not freed. Signed-off-by: Kostiantyn Kostiuk Signed-off-by: Kostiantyn Kostiuk Reviewed-by: Marc-Andr=C3=A9 Lureau --- qga/commands-win32.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 12f7a88078..cef14a8762 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -515,6 +515,8 @@ DEFINE_GUID(GUID_DEVINTERFACE_STORAGEPORT, static GuestPCIAddress *get_pci_info(int number, Error **errp) { HDEVINFO dev_info =3D INVALID_HANDLE_VALUE; + HDEVINFO parent_dev_info =3D INVALID_HANDLE_VALUE; + SP_DEVINFO_DATA dev_info_data; SP_DEVICE_INTERFACE_DATA dev_iface_data; HANDLE dev_file; @@ -542,7 +544,6 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) PSP_DEVICE_INTERFACE_DETAIL_DATA pdev_iface_detail_data =3D NULL; STORAGE_DEVICE_NUMBER sdn; char *parent_dev_id =3D NULL; - HDEVINFO parent_dev_info; SP_DEVINFO_DATA parent_dev_info_data; DWORD j; DWORD size =3D 0; @@ -744,11 +745,13 @@ static GuestPCIAddress *get_pci_info(int number, Erro= r **errp) break; } } - SetupDiDestroyDeviceInfoList(parent_dev_info); break; } cleanup: + if (parent_dev_info !=3D INVALID_HANDLE_VALUE) { + SetupDiDestroyDeviceInfoList(parent_dev_info); + } if (dev_info !=3D INVALID_HANDLE_VALUE) { SetupDiDestroyDeviceInfoList(dev_info); } -- 2.25.1 From nobody Mon Feb 9 13:07:19 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1639394698; cv=none; d=zohomail.com; s=zohoarc; b=bgqdpsGFhpCMpbJYsH5eKP50Nww5Wo6EaIlDmF771jnngChmO8BbuZ0fVV41WuxvamI3L+5lLO9B50z6xiEdzgaL4REkviwDW9x6M87n0db1IPhqc+yI6P2/BeC94SJLkookOIam55qP1vlrxL6aQrVcweTsgdW/eHoltbqXdnE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639394698; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7sBF+Qy7/vzAjQ+8VJmnouHX5HxqVw+CgpLyJxT4k1k=; b=GUItANBZuXrWX2GwJguQ2f1dsCoiLswPV+pXFSdSd/+SdbyLsQIbUVSylU2ZNvqxonz6xB5NN2uWKDVaMmr0HYwzwsC+CTeOKx09fijzEUBzMx2c39umHlcW8A7LH6MDZLfMQND19vZBzDfwQ1MCkOX9OErNozufjweqBo+VLro= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1639394698090475.7495930682969; Mon, 13 Dec 2021 03:24:58 -0800 (PST) Received: from localhost ([::1]:44260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mwjRx-0001Bk-1E for importer@patchew.org; Mon, 13 Dec 2021 06:24:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47560) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mwjJW-0008WI-Fs for qemu-devel@nongnu.org; Mon, 13 Dec 2021 06:16:15 -0500 Received: from [2a00:1450:4864:20::52f] (port=37457 helo=mail-ed1-x52f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mwjJT-0007Fp-9j for qemu-devel@nongnu.org; Mon, 13 Dec 2021 06:16:13 -0500 Received: by mail-ed1-x52f.google.com with SMTP id e3so51520323edu.4 for ; Mon, 13 Dec 2021 03:16:10 -0800 (PST) Received: from kostyanf14nb.Dlink ([37.72.42.118]) by smtp.gmail.com with ESMTPSA id a13sm6139384edk.29.2021.12.13.03.16.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 03:16:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=7sBF+Qy7/vzAjQ+8VJmnouHX5HxqVw+CgpLyJxT4k1k=; b=NRqDmXorx8tsujvCUJOAt/z7zgkL29eL4O4bpgM4Jotg4Odx33X2p3ICUmSNY25cv2 7QiMBSXHb8+9mxMzhGEWp1CBfZyLYA+H0PQhWTyZM5rWU+BxB2v96CdHZlBT5V8IHhge qhDFaBb6UajJ+aVArA4oMW6+cwqMU8CcxErYZ67uyd0pcPZRQ8Q0Y9yfXfWXre//FeC3 pZhUaxXf/6P7/flMfdladYBnrcN83yydG0Z7nKqsQCaPHC3ogViFcFy97t+i8bD2PRyl gAKrynHNg18+VZiqKmh0rJ+1qteb8ZCCFuYKswbNPK7m6GaOGtbunRzDMh/0Gl4h1Lxv PF1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7sBF+Qy7/vzAjQ+8VJmnouHX5HxqVw+CgpLyJxT4k1k=; b=d2jCkqup0l0JLy8+bC7xyblnMqLOvrssxpX4ZwnWWkx0zMsYrT0f5BrHOaMzvqR4vM b4z8CoBBdI4ZfKZHxmgEcHDEinP8UnQAdxsHgPf/tyoL70Jk/BQMUfzEhX0Qx8AyEuP+ 6DjOEFvMepxjgKdA2nz6+MqZsyGN3PVpEWbGauEXNg+cVTaadJ4uW2sIyy3TQEACa1Z/ aKliwry1SWxg+W3cZjQpCASIPYDz7Q439TWOYCgKpnSBBlt3UO9QnpJisjWBmnl9Le5p jSzxw61LJsOounnGY8LlhBn78IsDJbmLHm7v0N9butENCse6+wO1Mm7m4Lm5UGIE2bPW gz4g== X-Gm-Message-State: AOAM5304vP+LY8Wc+kqYpb3WE+DY4Mvei4ubxoEsZU6exsBRApFvIVhj tA9MR9a2v36Tcf43ETihPbReaKKfS90unw== X-Google-Smtp-Source: ABdhPJyxaZbWeHq0nWOg9jKWpG8hywPhAzhu9QiMaeVHylK8lEQW3sxZtullFO5O//WCL5dFYhh54A== X-Received: by 2002:aa7:d748:: with SMTP id a8mr63669081eds.21.1639394169212; Mon, 13 Dec 2021 03:16:09 -0800 (PST) From: Kostiantyn Kostiuk To: qemu-devel@nongnu.org, Michael Roth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 4/5] gqa-win: get_pci_info: Replace 'while' with 2 calls of the function Date: Mon, 13 Dec 2021 13:15:53 +0200 Message-Id: <20211213111554.62394-5-konstantin@daynix.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211213111554.62394-1-konstantin@daynix.com> References: <20211213111554.62394-1-konstantin@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::52f (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::52f; envelope-from=konstantin@daynix.com; helo=mail-ed1-x52f.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1639394699481100001 Content-Type: text/plain; charset="utf-8" Microsoft suggests this solution in the documentation: https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-set= updigetdeviceinterfacedetaila Signed-off-by: Kostiantyn Kostiuk Signed-off-by: Kostiantyn Kostiuk Reviewed-by: Marc-Andr=C3=A9 Lureau --- qga/commands-win32.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index cef14a8762..6bde5260e8 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -552,10 +552,10 @@ static GuestPCIAddress *get_pci_info(int number, Erro= r **errp) if (SetupDiEnumDeviceInterfaces(dev_info, &dev_info_data, &GUID_DEVINTERFACE_DISK, 0, &dev_iface_data)) { - while (!SetupDiGetDeviceInterfaceDetail(dev_info, &dev_iface_d= ata, - pdev_iface_detail_data, - size, &size, - &dev_info_data)) { + if (!SetupDiGetDeviceInterfaceDetail(dev_info, &dev_iface_data, + pdev_iface_detail_data, + size, &size, + &dev_info_data)) { if (GetLastError() =3D=3D ERROR_INSUFFICIENT_BUFFER) { pdev_iface_detail_data =3D g_malloc(size); pdev_iface_detail_data->cbSize =3D @@ -567,6 +567,16 @@ static GuestPCIAddress *get_pci_info(int number, Error= **errp) } } + if (!SetupDiGetDeviceInterfaceDetail(dev_info, &dev_iface_data, + pdev_iface_detail_data, + size, &size, + &dev_info_data)) { + // pdev_iface_detail_data already is allocated + error_setg_win32(errp, GetLastError(), + "failed to get device interfaces"); + goto cleanup; + } + dev_file =3D CreateFile(pdev_iface_detail_data->DevicePath, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); @@ -597,8 +607,8 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) ULONG dev_id_size =3D 0; size =3D 0; - while (!SetupDiGetDeviceInstanceId(dev_info, &dev_info_data, - parent_dev_id, size, &size)= ) { + if (!SetupDiGetDeviceInstanceId(dev_info, &dev_info_data, + parent_dev_id, size, &size)) { if (GetLastError() =3D=3D ERROR_INSUFFICIENT_BUFFER) { parent_dev_id =3D g_malloc(size); } else { @@ -608,6 +618,14 @@ static GuestPCIAddress *get_pci_info(int number, Error= **errp) } } + if (!SetupDiGetDeviceInstanceId(dev_info, &dev_info_data, + parent_dev_id, size, &size)) { + // parent_dev_id already is allocated + error_setg_win32(errp, GetLastError(), + "failed to get device instance ID"); + goto cleanup; + } + /* * CM API used here as opposed to * SetupDiGetDeviceProperty(..., DEVPKEY_Device_Parent, ...) -- 2.25.1 From nobody Mon Feb 9 13:07:19 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1639394467; cv=none; d=zohomail.com; s=zohoarc; b=IeLfeliMyoXb2z0dYDxUOmxsddI9HiTeG8waRkUlsVp16/ibeMOeJONeGDa7bMerRSpHAwcEqqy4BloFEk97QyB+TAw/+rZq5iQMLQN3e9pLEKqsR004X54FXestoezV4pVoRsy+j6jWvwNeTOargNn+SeqHWupxrAaqQBv9nQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639394467; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ahhw9F7FEinJ7VZiCiD3/+4+Y4DOuDMMwasuLCf6UN0=; b=Tay2V2fPic3GeHK0YOn5yA19jdkw2pz1tLqT3LRWlIYYqSbYdhcHAGQPpDxeA7EcJCs66FXmez+8Qcnj2AZa/tANT0G8SXnVMpMOFTbY5g6eaMUY0aE9794qW2eRVPxDYqpTd/OJ7esvU47Sxk0hdBAtyou1ZSclRscX9MKqHBI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1639394467170841.1735820778788; Mon, 13 Dec 2021 03:21:07 -0800 (PST) Received: from localhost ([::1]:38432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mwjOE-0005bc-3x for importer@patchew.org; Mon, 13 Dec 2021 06:21:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mwjJV-0008WF-VO for qemu-devel@nongnu.org; Mon, 13 Dec 2021 06:16:15 -0500 Received: from [2a00:1450:4864:20::531] (port=43549 helo=mail-ed1-x531.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mwjJT-0007Fz-Gd for qemu-devel@nongnu.org; Mon, 13 Dec 2021 06:16:13 -0500 Received: by mail-ed1-x531.google.com with SMTP id o20so51234304eds.10 for ; Mon, 13 Dec 2021 03:16:11 -0800 (PST) Received: from kostyanf14nb.Dlink ([37.72.42.118]) by smtp.gmail.com with ESMTPSA id a13sm6139384edk.29.2021.12.13.03.16.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 03:16:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ahhw9F7FEinJ7VZiCiD3/+4+Y4DOuDMMwasuLCf6UN0=; b=YqCKeXmmTy8qs3Wv2aSbGTmUGiyPPwEk2J0Zyiv5jBA0czawUgt2KGcfQefhG2mvwc z/62GytR5kWw03mVQE1Ynmlc30WPh9QCpjqUT5Oy5FY/bWDfl3qaJ2akRP2DEqLa7EFk yFs27pZPhwr0Liurndf81F89HyLAT0WVz/STnuBwkMpzyPIWosaX9xkuOKtkqRRg3oTt /wQWgIsmaZ7mB/omZumM8+7iKcMM0NwuKLDmvoes8Sx4tAR9VGlztE1PSax6INqzWZp9 DENXFHdKvYmaZ1ufKy7dOC4Ya2wo5I1SJXQCv7V+xMT5UAskRj9v5N6MZaS9Jw8S9ivG 6LAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ahhw9F7FEinJ7VZiCiD3/+4+Y4DOuDMMwasuLCf6UN0=; b=oPjTJzAfbgv/abRytc3UuXOuOvhOtfPGSXmemuLwz6qDHKK1igcGP9i+Ey6dOWbgky Az1+eBaCpNS9p75zPtRggzo7jY4y47QXcOvh93fuRpJzvVKvpqPd3N4yWrM7BlvAKsjj /qGtHprfoCn1JbGEBpWO79NdiSXqt5xuAffR7sauzLM8E8ns5/93tHtotp8va75qR4U8 6xmGnhDt0v2O3F7ocYkCzDp9beOwvbxYhsXL5ILNIkLCG6UZcafnYAh06TsQ5klsQ7bt qp5Zfs3fVRyU481R/QmCZ8o54MT6LFMbRylLGCGm1/z9dvd13rAUMdlTTO24pgJwh+Ci U1UA== X-Gm-Message-State: AOAM533afP/go1wk253vFU6TTM1Jnide3m+dqIwZwxMdXqhk9g9yeiNz eEW+LEKZA38LYtBFBc3K8Rb6qh/ybQZCFw== X-Google-Smtp-Source: ABdhPJwLJ9XPvD/vgZyDGkiARsmNhVaYIQFvJ7wQBvfFsXg6SIUpEnPY9galYbuMO5nSXJpzHh3SAg== X-Received: by 2002:a50:da48:: with SMTP id a8mr63232311edk.155.1639394170115; Mon, 13 Dec 2021 03:16:10 -0800 (PST) From: Kostiantyn Kostiuk To: qemu-devel@nongnu.org, Michael Roth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 5/5] gqa-win: get_pci_info: Add g_autofree for few variables Date: Mon, 13 Dec 2021 13:15:54 +0200 Message-Id: <20211213111554.62394-6-konstantin@daynix.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211213111554.62394-1-konstantin@daynix.com> References: <20211213111554.62394-1-konstantin@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::531 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::531; envelope-from=konstantin@daynix.com; helo=mail-ed1-x531.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1639394468353100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kostiantyn Kostiuk Signed-off-by: Kostiantyn Kostiuk Reviewed-by: Marc-Andr=C3=A9 Lureau --- qga/commands-win32.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 6bde5260e8..96737f33e1 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -541,9 +541,9 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) dev_info_data.cbSize =3D sizeof(SP_DEVINFO_DATA); dev_iface_data.cbSize =3D sizeof(SP_DEVICE_INTERFACE_DATA); for (i =3D 0; SetupDiEnumDeviceInfo(dev_info, i, &dev_info_data); i++)= { - PSP_DEVICE_INTERFACE_DETAIL_DATA pdev_iface_detail_data =3D NULL; + g_autofree PSP_DEVICE_INTERFACE_DETAIL_DATA pdev_iface_detail_data= =3D NULL; STORAGE_DEVICE_NUMBER sdn; - char *parent_dev_id =3D NULL; + g_autofree char *parent_dev_id =3D NULL; SP_DEVINFO_DATA parent_dev_info_data; DWORD j; DWORD size =3D 0; @@ -580,7 +580,6 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) dev_file =3D CreateFile(pdev_iface_detail_data->DevicePath, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - g_free(pdev_iface_detail_data); if (!DeviceIoControl(dev_file, IOCTL_STORAGE_GET_DEVICE_NUMBER, NULL, 0, &sdn, sizeof(sdn), &size, NULL))= { @@ -675,7 +674,6 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) parent_dev_info =3D SetupDiGetClassDevs(&GUID_DEVINTERFACE_STORAGEPORT, parent_dev= _id, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFAC= E); - g_free(parent_dev_id); if (parent_dev_info =3D=3D INVALID_HANDLE_VALUE) { error_setg_win32(errp, GetLastError(), -- 2.25.1