From nobody Wed Apr 24 07:04:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1596110770; cv=none; d=zohomail.com; s=zohoarc; b=GvZ8dHTVvSCzjfaUAOUdA/3Fo0rij700dhR06uTgxOpeP2SQncuJQwhbFmBiGKvmF9MDCn8qMVerDBT+fp25DhMV32fjQvmnr9dA2JMM+vsfuFNLnYR6aqC3FNwvDNfmHi1ahAYhk1ABkkcAThtm0fupsEbeXaNiN39Y/bPbJtc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596110770; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=/DOAjiub/5d79G7kDNXoVLK8dQTwwj5D/YwnwG/IszY=; b=HUX2OKRgZS8jY8rfWzcd0Ns+M2TOU3Chwqmb6vF+GbOTl0XUB9bh++JLsAjkce12oUjza9rK07zacdp7lTxW7+4p5ordZP/uSR768KlyQm267osgl9cmTS6yLkDb3KWLDO2E3rzE+wQyut86PnbaWDxeu1CxIu+7rT8kdf1oYoY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1596110770480869.9369322737926; Thu, 30 Jul 2020 05:06:10 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-27-LJpoloT7P9eshfMC44ilMQ-1; Thu, 30 Jul 2020 08:06:06 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8649019253C2; Thu, 30 Jul 2020 12:06:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9046C70105; Thu, 30 Jul 2020 12:05:58 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A0F689A0F7; Thu, 30 Jul 2020 12:05:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06UC3Rpi032225 for ; Thu, 30 Jul 2020 08:03:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7D0132029F77; Thu, 30 Jul 2020 12:03:27 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3AF332029F7A for ; Thu, 30 Jul 2020 12:03:21 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C419018ABF81 for ; Thu, 30 Jul 2020 12:03:21 +0000 (UTC) Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-493-eoLeqn2tN5eyhbKGgMJr-Q-1; Thu, 30 Jul 2020 08:03:18 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 688566AA655007F47933 for ; Thu, 30 Jul 2020 20:03:15 +0800 (CST) Received: from [127.0.0.1] (10.174.187.164) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Thu, 30 Jul 2020 20:03:09 +0800 X-MC-Unique: LJpoloT7P9eshfMC44ilMQ-1 X-MC-Unique: eoLeqn2tN5eyhbKGgMJr-Q-1 To: From: Hao Wang Subject: [PATCH] virNodeDevPCICapSRIOVVirtualParseXML: fix memleak of addr Message-ID: <4a221ca4-0296-926b-4147-e70def3bf3bc@huawei.com> Date: Thu, 30 Jul 2020 20:03:08 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 X-Originating-IP: [10.174.187.164] X-CFilter-Loop: Reflected X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: "Chenzhendong \(alex\)" , zhengchuan , Zhanghailiang , yubihong X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Hao Wang Subject: [PATCH] virNodeDevPCICapSRIOVVirtualParseXML: fix memleak of addr virPCIDeviceAddressPtr 'addr' is forgotten to be freed in the branch 'VIR_APPEND_ELEMENT() < 0'. Use g_autoptr instead. Signed-off-by: Hao Wang Reviewed-by: Michal Privoznik --- src/conf/node_device_conf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index c54015336a..2f63772917 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1489,15 +1489,13 @@ virNodeDevPCICapSRIOVVirtualParseXML(xmlXPathContex= tPtr ctxt, goto cleanup; for (i =3D 0; i < naddresses; i++) { - virPCIDeviceAddressPtr addr =3D NULL; + g_autoptr(virPCIDeviceAddress) addr =3D NULL; if (VIR_ALLOC(addr) < 0) goto cleanup; - if (virPCIDeviceAddressParseXML(addresses[i], addr) < 0) { - VIR_FREE(addr); + if (virPCIDeviceAddressParseXML(addresses[i], addr) < 0) goto cleanup; - } if (VIR_APPEND_ELEMENT(pci_dev->virtual_functions, pci_dev->num_virtual_functions, -- 2.23.0