From nobody Sun Apr 28 14:06:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568879785; cv=none; d=zoho.com; s=zohoarc; b=QwQLSb8UT2eX198oGHkJFmW1fQzwGXtZJV/YWRD5cmmpt0QYJm/8rsXDkm+C1QqmQlXwFiAnsRyDXj13xiYVj++b8WaVIHf5stYEPln03sW/bD050kr7MBJvZO3dT4KfvfCBPj/9uSpWPmBjWc84HGbDn3YR3ffh3o2QhpQf4fA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568879785; 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:ARC-Authentication-Results; bh=OoispTeqREoIQJCQkmJS3HEE91cns/yxjK8MkJo04HM=; b=cs1ZJcD6evQ+4e3C0hGHRXFUkDN3iKjPXdnBoe422Ly56eJVLwxfr201XFmeU3wrjJoslisnauy7ElioEixYzI1VwIIgiDOpQBoyOiPZrbaeXZ3OPCaXC05Idclq34I3iZ/4tuq/5wGPhZ9uq9kVKQlprT2ia9Zjbrfylo5hPoY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1568879785334716.0987023663405; Thu, 19 Sep 2019 00:56:25 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A59A690C99; Thu, 19 Sep 2019 07:56:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7F18C5C226; Thu, 19 Sep 2019 07:56:23 +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 41C821803518; Thu, 19 Sep 2019 07:56:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8J7uMaK032550 for ; Thu, 19 Sep 2019 03:56:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 075CE60C5D; Thu, 19 Sep 2019 07:56:22 +0000 (UTC) Received: from mx1.redhat.com (ext-mx29.extmail.prod.ext.phx2.redhat.com [10.5.110.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0193C60CCD for ; Thu, 19 Sep 2019 07:56:19 +0000 (UTC) Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BAEB418C8900 for ; Thu, 19 Sep 2019 07:56:18 +0000 (UTC) Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 2F751787FDB290D403C5 for ; Thu, 19 Sep 2019 15:56:17 +0800 (CST) Received: from localhost (10.175.124.177) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.439.0; Thu, 19 Sep 2019 15:56:07 +0800 From: Xu Yandong To: Date: Thu, 19 Sep 2019 04:01:31 -0400 Message-ID: <1568880091-88040-1-git-send-email-xuyandong2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.177] X-CFilter-Loop: Reflected X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.70]); Thu, 19 Sep 2019 07:56:18 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.70]); Thu, 19 Sep 2019 07:56:18 +0000 (UTC) for IP:'45.249.212.32' DOMAIN:'szxga06-in.huawei.com' HELO:'huawei.com' FROM:'xuyandong2@huawei.com' RCPT:'' X-RedHat-Spam-Score: -2.302 (RCVD_IN_DNSWL_MED, SPF_HELO_PASS, SPF_PASS) 45.249.212.32 szxga06-in.huawei.com 45.249.212.32 szxga06-in.huawei.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.70 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Xu Yandong , zhang.zhanghailiang@huawei.com Subject: [libvirt] [PATCH] conf: fix memory leak in virNodeDevPCICapSRIOVVirtualParseXML 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 19 Sep 2019 07:56:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" In function virNodeDevPCICapSRIOVVirtualParseXML, temp variable addr could leak if VIR_APPEND_ELEMENT fails . Signed-off-by: Xu Yandong Reviewed-by: Daniel Henrique Barboza --- src/conf/node_device_conf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 618ce8e00e..2d8e03e53e 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1519,8 +1519,10 @@ virNodeDevPCICapSRIOVVirtualParseXML(xmlXPathContext= Ptr ctxt, =20 if (VIR_APPEND_ELEMENT(pci_dev->virtual_functions, pci_dev->num_virtual_functions, - addr) < 0) + addr) < 0) { + VIR_FREE(addr); goto cleanup; + } } =20 pci_dev->flags |=3D VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION; --=20 2.18.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list