From patchwork Mon Aug 9 09:48:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Kostiuk X-Patchwork-Id: 12426089 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7A1FC4338F for ; Mon, 9 Aug 2021 09:50:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 052A6601FD for ; Mon, 9 Aug 2021 09:50:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 052A6601FD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:58350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mD1vt-00018g-Tn for qemu-devel@archiver.kernel.org; Mon, 09 Aug 2021 05:50:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mD1tt-0005MP-W1 for qemu-devel@nongnu.org; Mon, 09 Aug 2021 05:48:54 -0400 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]:47021) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mD1tr-00022w-HP for qemu-devel@nongnu.org; Mon, 09 Aug 2021 05:48:53 -0400 Received: by mail-lf1-x12b.google.com with SMTP id n17so7366205lft.13 for ; Mon, 09 Aug 2021 02:48:50 -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:mime-version :content-transfer-encoding; bh=u+s872iwqWhG+7366PB9FReKLpoScW/sp/avFSq0/ME=; b=SesbIWULulFBBJcDo3MolAhwmCpuiQQPqF/A5xZcilWBVi/yopVAzT+XZe8szDh/5p /7Jm8XudZEb6/MrcnYY4L+190+J68X7m01Rw+DOcK3E38LlcgZmjzbdmLa1emeGD5+Ka 9fF/uZ1Q+UF6TlyLqhTjO3cYh5J8nA70Qa8/cKQMMDSXDKBGjszslvs4dJ15h1xXwxuk P0Wml/PR6d7KIeQTPKET0geNBC/1oTxi2DE+tRIHRcKzKUYX67U6Fo8BnambboTFG7x8 RPevkQQ/EZL2thr4ZTkIdnpMEOknrA3pdbw4KKStYvPrF1x4MVdZXp5Q4ypRD5fNrPq5 Lm7g== 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:mime-version :content-transfer-encoding; bh=u+s872iwqWhG+7366PB9FReKLpoScW/sp/avFSq0/ME=; b=QruFN3y8Sm9n68g0F3vYWnXktNOWpzXm5N/5FnJNmKFE4ufY39wZQHu0UVVp3NRVfq r8pR6+/OyrzpId5jKhRuRnBdZdObT81NCJveU0sY3goIaiq7s1KIoAmU2wtrfMkdZeHJ jCxijjl203YDFnxid+ufFPIVJkC3n2UgUyWWOC8HHYHrhTjUMZA5NsMfTSXb3LkCp88d 7IMS7LpzOuNx2diQTGRGhBgfQUBoYOX0wKpzP3N3X51j8HEDFvwtsi6vJvfBDs0fmO7S d1uVY3ZKcVX4IjWXBtB1nMeqh/wep3l++pbI+vdBBx7q2c/lPcdPzOeydVPCxvaTRH48 4A2A== X-Gm-Message-State: AOAM532mbq5YaWRFtQ86bcU7ofyNjR9D1eS7CwpfbOQfth4L3lDqvkvS P0QG79NCfvcoOlbaODpStpLklVmQW8C4ZPSTbMg= X-Google-Smtp-Source: ABdhPJxoGYBKjidQh2xJnVW2B1sr5z0fPnn2hKCDigrDx8MhEPmWnGV91wZ5FwlePmfcT04i/3hRoA== X-Received: by 2002:a05:6512:b27:: with SMTP id w39mr7653396lfu.129.1628502528555; Mon, 09 Aug 2021 02:48:48 -0700 (PDT) Received: from kostyanf14nb.Dlink (93-77-45-80.vin.volia.net. [93.77.45.80]) by smtp.gmail.com with ESMTPSA id q20sm1681506lfo.19.2021.08.09.02.48.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 02:48:48 -0700 (PDT) From: Kostiantyn Kostiuk To: qemu-devel@nongnu.org Subject: [RFC 1/4] gqa-win: get_pci_info: Clean dev_info if handle is valid Date: Mon, 9 Aug 2021 12:48:36 +0300 Message-Id: <20210809094839.52312-1-konstantin@daynix.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Received-SPF: none client-ip=2a00:1450:4864:20::12b; envelope-from=konstantin@daynix.com; helo=mail-lf1-x12b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , Matt Hines , Michael Roth Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Kostiantyn Kostiuk --- 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 27baf17d6c..2ad8593b82 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 = 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 != INVALID_HANDLE_VALUE) { + SetupDiDestroyDeviceInfoList(dev_info); + } out: return pci; } From patchwork Mon Aug 9 09:48:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Kostiuk X-Patchwork-Id: 12426093 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08B3CC4338F for ; Mon, 9 Aug 2021 09:52:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4B0F860F11 for ; Mon, 9 Aug 2021 09:52:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4B0F860F11 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:36480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mD1xZ-0005Sn-Am for qemu-devel@archiver.kernel.org; Mon, 09 Aug 2021 05:52:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50830) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mD1tv-0005Q9-BI for qemu-devel@nongnu.org; Mon, 09 Aug 2021 05:48:55 -0400 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]:37644) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mD1tr-00023H-Mg for qemu-devel@nongnu.org; Mon, 09 Aug 2021 05:48:55 -0400 Received: by mail-lf1-x133.google.com with SMTP id g30so371635lfv.4 for ; Mon, 09 Aug 2021 02:48:50 -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 :mime-version:content-transfer-encoding; bh=MZR+RF/C02tQXEliHb6SZNlilZioJS19xcXK6m2c6sY=; b=ZQAjdXC6cFEQs5cn2kpSGAvxBOAJxSja/Rky2I6F75FAZxIcMh3aFKfksBuOpsiXWj NNANelmcRzTogQufv0LboIqDhpGZHpUqVBROOAEToJwjHjXPntEZu7b9frNOhXWOhhXA j2BjAz4GKgg9C5c6xZljcif4PB97/X0jDW1FjGAqfbItbOZ8FNTeCT8i8+p4z9EHIzIV heAl/MRiwQSyX8w3+VaSYQR92auPXFk3cW6OBWONuTBJ1QPPjxQgXuIwcQSYHv4xofL3 Mq32qYz9X3Croqz5wIVLms0j0Dsp+BHpMYXjBealvVO7yNPr3IsTFInPRoAr9DNK/p7V cUsQ== 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=MZR+RF/C02tQXEliHb6SZNlilZioJS19xcXK6m2c6sY=; b=nbWle3znMPrqaCdX1ACRJR/DI4uvswiLCKg0SyN5iDRroDmLiKv6ZJm78IHxKDEgnQ 5BU9PQRIbxkXDt3ldGCfmrNY5JRM4Ct6v1zxYFx8rXR05Hc16uI24AUs6MsCnTGSWkpq bCCNjTxaKGcgHeShjqQvv6YGmm1OHEPQtCqIw/cbDpNyl08/qSBWwRlqSCtT3mk43rzi SHKNj5PmY7LdITvXnqVvkKtWclNUekhQE/jz3Ai4+StoyuviM7majgGStXt0VIGj7MGV WOitNAxlyDI564YmW0Ugh9/5eI+v1/1dvj/p//4LPbZGg0t9UPT3Y6RaPtvb31ZEcofG jVNw== X-Gm-Message-State: AOAM531Vb2+mF7+gblQvvd+hBWRDu+CiPBReSu8ZnGESnulK+mEBjqKK W8JHK3ANTmJAzg7Xsat4IG92R6zoS/vGv5+u3ws= X-Google-Smtp-Source: ABdhPJxJlMovfOV25bi4XINWb30B5edrjXa7U1+b8gnYGCgclT5m/XN6kwPUOiYqk9WcMXYVuv0HKw== X-Received: by 2002:a05:6512:3d8d:: with SMTP id k13mr17753061lfv.394.1628502529526; Mon, 09 Aug 2021 02:48:49 -0700 (PDT) Received: from kostyanf14nb.Dlink (93-77-45-80.vin.volia.net. [93.77.45.80]) by smtp.gmail.com with ESMTPSA id q20sm1681506lfo.19.2021.08.09.02.48.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 02:48:49 -0700 (PDT) From: Kostiantyn Kostiuk To: qemu-devel@nongnu.org Subject: [RFC 2/4] gqa-win: get_pci_info: Use common 'cleanup' label Date: Mon, 9 Aug 2021 12:48:37 +0300 Message-Id: <20210809094839.52312-2-konstantin@daynix.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210809094839.52312-1-konstantin@daynix.com> References: <20210809094839.52312-1-konstantin@daynix.com> MIME-Version: 1.0 Received-SPF: none client-ip=2a00:1450:4864:20::133; envelope-from=konstantin@daynix.com; helo=mail-lf1-x133.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , Matt Hines , Michael Roth Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" To prevent memory leaks, always try to free initialized variables. Signed-off-by: Kostiantyn Kostiuk --- 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 2ad8593b82..724ce76a0e 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 == 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, Error **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 = CM_Get_Parent(&parent_dev_inst, dev_inst, 0); if (cr != 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 = 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, Error **errp) if (parent_dev_info == INVALID_HANDLE_VALUE) { error_setg_win32(errp, GetLastError(), "failed to get parent device"); - goto out; + goto cleanup; } parent_dev_info_data.cbSize = sizeof(SP_DEVINFO_DATA); if (!SetupDiEnumDeviceInfo(parent_dev_info, 0, &parent_dev_info_data)) { error_setg_win32(errp, GetLastError(), "failed to get parent device data"); - goto out; + goto cleanup; } for (j = 0; @@ -748,11 +748,10 @@ static GuestPCIAddress *get_pci_info(int number, Error **errp) break; } -free_dev_info: +cleanup: if (dev_info != INVALID_HANDLE_VALUE) { SetupDiDestroyDeviceInfoList(dev_info); } -out: return pci; } From patchwork Mon Aug 9 09:48:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Kostiuk X-Patchwork-Id: 12426079 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DBDBC4320A for ; Mon, 9 Aug 2021 09:49:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EC2BB60F11 for ; Mon, 9 Aug 2021 09:49:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EC2BB60F11 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:55322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mD1ut-0007XC-VZ for qemu-devel@archiver.kernel.org; Mon, 09 Aug 2021 05:49:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mD1tu-0005O3-H2 for qemu-devel@nongnu.org; Mon, 09 Aug 2021 05:48:54 -0400 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]:34790) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mD1ts-000243-80 for qemu-devel@nongnu.org; Mon, 09 Aug 2021 05:48:54 -0400 Received: by mail-lj1-x230.google.com with SMTP id m18so11462344ljo.1 for ; Mon, 09 Aug 2021 02:48:51 -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 :mime-version:content-transfer-encoding; bh=aKDh2Pfz9WYAi8UXtHOjegiva+s1ZUtl0NaOopyyCU4=; b=cFV+wF02/qwBtBxgTQrWAGCFAdt2RWZgvM2X9id1OaTlncUe0NN4ZJTmIUOZcdDrQe aCmdV3gqInr77S4o/imdsEoDuEPaGFy5FJ0QAPCoMOr4u2dPaMVWaRwXW/zsxYA7xo3O mo/kee5CeHvCxzIRQt6GVavhoY+FVMPYF3rsBnpaLT6er0oPLEp3QVvwzBYdkF24GfLE boWbxZ6EVK2ybTvG0HrFmTHV8QUMGGU5aY9J8sPEXXynxkii5AxeUTcaNvK+wv3lVBUW oo3wHO/Jyxp1tQeVuR3KVrAOx3Sgd4X6fIDK8aozQL3lo3z7QmHWyct1+yI0VvI2wlli ZnnQ== 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=aKDh2Pfz9WYAi8UXtHOjegiva+s1ZUtl0NaOopyyCU4=; b=qOHi7ldPVDngL+6hZiZVMCanq6nmw7/iBvWROK6vg9PVK1gySnCBg/zLeoYpB1pz2m 0Dyu1BulbOo7DCwo9Z6huCoKbMD4nLnAX6r336UTEOMCpJIMEFWmp2zZKDveEv9e6tUG gJLeZKjjcRIUr3V01D9a9M+5LiKOnm8aZ3pgA2o2oRInIBve0MrUJZ9UE24cznFTvyq8 2Os6gMIYvOjFFodeYozt5JrNXAIuZ1VqIo3lQdrOgMO+UYsrCwLHnLnRMy8EebGmAxj3 Tv25lRtSOYxsyIjOgKAqT0entZxkkaAsvXhgD04upa/4ig8BEgzI1s1jgmICyS18tAA+ opLw== X-Gm-Message-State: AOAM530Q+h9Ph5tOIPRlfHKzvOGgB5YxmvwRR2yiT/Apt6SyoMTsk8Us UmoPMm4cBtEVU8Tw2kY4UL8Ionp7w2xpS0vA8Xo= X-Google-Smtp-Source: ABdhPJyDlQPFsvLBwwqOCz0lTJYLqVq9QUITqqgXNtGXZ4cHxkpNoM5ZZHhw/+fA0Fw0s7kZ0ugn9w== X-Received: by 2002:a2e:8e68:: with SMTP id t8mr15410137ljk.353.1628502530513; Mon, 09 Aug 2021 02:48:50 -0700 (PDT) Received: from kostyanf14nb.Dlink (93-77-45-80.vin.volia.net. [93.77.45.80]) by smtp.gmail.com with ESMTPSA id q20sm1681506lfo.19.2021.08.09.02.48.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 02:48:50 -0700 (PDT) From: Kostiantyn Kostiuk To: qemu-devel@nongnu.org Subject: [RFC 3/4] gqa-win: get_pci_info: Add g_autofree for few variables Date: Mon, 9 Aug 2021 12:48:38 +0300 Message-Id: <20210809094839.52312-3-konstantin@daynix.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210809094839.52312-1-konstantin@daynix.com> References: <20210809094839.52312-1-konstantin@daynix.com> MIME-Version: 1.0 Received-SPF: none client-ip=2a00:1450:4864:20::230; envelope-from=konstantin@daynix.com; helo=mail-lj1-x230.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , Matt Hines , Michael Roth Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Kostiantyn Kostiuk --- qga/commands-win32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 724ce76a0e..a8a601776d 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -539,9 +539,9 @@ static GuestPCIAddress *get_pci_info(int number, Error **errp) dev_info_data.cbSize = sizeof(SP_DEVINFO_DATA); dev_iface_data.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); for (i = 0; SetupDiEnumDeviceInfo(dev_info, i, &dev_info_data); i++) { - PSP_DEVICE_INTERFACE_DETAIL_DATA pdev_iface_detail_data = NULL; + g_autofree PSP_DEVICE_INTERFACE_DETAIL_DATA pdev_iface_detail_data = NULL; STORAGE_DEVICE_NUMBER sdn; - char *parent_dev_id = NULL; + g_autofree char *parent_dev_id = NULL; HDEVINFO parent_dev_info; SP_DEVINFO_DATA parent_dev_info_data; DWORD j; From patchwork Mon Aug 9 09:48:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Kostiuk X-Patchwork-Id: 12426091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5F68C4320A for ; Mon, 9 Aug 2021 09:51:55 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0EC9A60F8F for ; Mon, 9 Aug 2021 09:51:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0EC9A60F8F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:33442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mD1wn-0003Qo-WC for qemu-devel@archiver.kernel.org; Mon, 09 Aug 2021 05:51:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mD1tu-0005Oe-Od for qemu-devel@nongnu.org; Mon, 09 Aug 2021 05:48:54 -0400 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]:38716) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mD1tt-00024J-59 for qemu-devel@nongnu.org; Mon, 09 Aug 2021 05:48:54 -0400 Received: by mail-lj1-x230.google.com with SMTP id u13so22715979lje.5 for ; Mon, 09 Aug 2021 02:48:52 -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 :mime-version:content-transfer-encoding; bh=HWm2i+e1T/OU0lMsw5Uz/IUId6ABDgvGYFnXkHseIWM=; b=etl+Xxi+rcWDvIHc40DwfIQ9yhTMUm1+9XFNk+TdVI60yAWyr4mjb2pnnMmSN7EOFd //vqVLcwxQD32nNYyhyMaNGknzVkXi1VdY37y1fiUz6j+PROQksA1ZvSCz44rnMkSaHy Y4NbemQwmiJHiHagWAImTRjG/8lwDddxU+lm01xYLwsKInxgBAfF41OZuC9VCEae9OVn udgcbmqEsOV/fIyFsH8Jkn1Dxj677l+0dCxZoFCTNC12YSeJ2tJVUagYVnhfA8rAU1Vq X3GJ6MoyhoOkMtvZnKYv2Ha8QwCMVWa2uhsS1uaIRpGljxTaigtepo5F9re/iABL8gwK DGew== 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=HWm2i+e1T/OU0lMsw5Uz/IUId6ABDgvGYFnXkHseIWM=; b=SHMOXBdS0CSnFE82N3eMJ9qS0jzhnjD2CenivnZi5pK8ah/hzRh63Dw4wGuOIpArw1 bYINfvVI7mheX//FaCwEMTFNWJ+B2uTE0BNDFJG5i62EPatOAozjX+AtWnTeVp6FtZwQ g9/BX9Ihd587idXCT+vrsf0cDW19AVfbImdlmfId3k8tnbL67atO8hw1yh1jgnC5FCLM GJVhn1QHrdib1oDw1bcghrqDA1Fab2bE/c1LGckmjk3J6+xm9wpWf98Hv5tGed6Sd4of IoNY1dMVMBpDVbNZDckgJuim8OrosvWQPKDK9Q+q2wLAh90o13VrpR3YfuzoyPOGiaix rCOA== X-Gm-Message-State: AOAM533Rwc2VHUtNG3uWKDVJDBjT9m8vKTFic89GofD8V6mCzzkndPh7 PW0Vt8t//1smp01A4dmLsfG+MEpabvIRB2nbyvs= X-Google-Smtp-Source: ABdhPJxpVnfCkocO1DMvI59DxEk/b+A2gpGQEwzSt0J0xxw8hmGxoESAQd65gSm6UTYJfxVWkH6SsQ== X-Received: by 2002:a2e:9e41:: with SMTP id g1mr15312364ljk.471.1628502531484; Mon, 09 Aug 2021 02:48:51 -0700 (PDT) Received: from kostyanf14nb.Dlink (93-77-45-80.vin.volia.net. [93.77.45.80]) by smtp.gmail.com with ESMTPSA id q20sm1681506lfo.19.2021.08.09.02.48.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 02:48:51 -0700 (PDT) From: Kostiantyn Kostiuk To: qemu-devel@nongnu.org Subject: [RFC 4/4] gqa-win: get_pci_info: Free parent_dev_info properly Date: Mon, 9 Aug 2021 12:48:39 +0300 Message-Id: <20210809094839.52312-4-konstantin@daynix.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210809094839.52312-1-konstantin@daynix.com> References: <20210809094839.52312-1-konstantin@daynix.com> MIME-Version: 1.0 Received-SPF: none client-ip=2a00:1450:4864:20::230; envelope-from=konstantin@daynix.com; helo=mail-lj1-x230.google.com X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , Matt Hines , Michael Roth Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- qga/commands-win32.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index a8a601776d..520c520cb8 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 = INVALID_HANDLE_VALUE; + HDEVINFO parent_dev_info = 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) g_autofree PSP_DEVICE_INTERFACE_DETAIL_DATA pdev_iface_detail_data = NULL; STORAGE_DEVICE_NUMBER sdn; g_autofree char *parent_dev_id = NULL; - HDEVINFO parent_dev_info; SP_DEVINFO_DATA parent_dev_info_data; DWORD j; DWORD size = 0; @@ -745,6 +746,7 @@ static GuestPCIAddress *get_pci_info(int number, Error **errp) } } SetupDiDestroyDeviceInfoList(parent_dev_info); + parent_dev_info = INVALID_HANDLE_VALUE; break; } @@ -752,6 +754,9 @@ cleanup: if (dev_info != INVALID_HANDLE_VALUE) { SetupDiDestroyDeviceInfoList(dev_info); } + if (parent_dev_info != INVALID_HANDLE_VALUE) { + SetupDiDestroyDeviceInfoList(parent_dev_info); + } return pci; }