From nobody Sun Apr 28 06:31:51 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; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=126.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1518318524714128.5291658794523; Sat, 10 Feb 2018 19:08:44 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 60CAF5B2F5; Sun, 11 Feb 2018 03:08:42 +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 9F5435D755; Sun, 11 Feb 2018 03:08:39 +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 64AB64A46C; Sun, 11 Feb 2018 03:08:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1B37VZ5014142 for ; Sat, 10 Feb 2018 22:07:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id EDFD85D75A; Sun, 11 Feb 2018 03:07:31 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E71A05D755 for ; Sun, 11 Feb 2018 03:07:29 +0000 (UTC) Received: from m15-114.126.com (m15-114.126.com [220.181.15.114]) by mx1.redhat.com (Postfix) with ESMTP id 3F98E5F742 for ; Sun, 11 Feb 2018 03:07:27 +0000 (UTC) Received: from localhost.localdomain (unknown [58.213.111.46]) by smtp7 (Coremail) with SMTP id DsmowABn68xms39a6EMZCA--.43595S2; Sun, 11 Feb 2018 11:07:25 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=IX+8dAklNnhTz+iT86 DznAn2rlZhJOQf57Cyg29mNxU=; b=ROkTjzE6Sj0OI4Mi4IEVr5Nhm29XNsZ5sW mr+pTO16cLQEg1XwzX2wenSI2+GrMfzlDL3MvNaTPVxcqfce1ZIbD2nAarnIYvmG RnzhRUzTcuzbJ7RWvQQnSTsvpS/0Bdg1of8Lzev5zr9e98YJRy5+QU7KWUAZypJ9 C1h34xkkc= From: Chen Hanxiao To: libvir-list@redhat.com Date: Sun, 11 Feb 2018 11:07:10 +0800 Message-Id: <20180211030710.7670-1-chen_han_xiao@126.com> X-CM-TRANSID: DsmowABn68xms39a6EMZCA--.43595S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7ZrWrJFy3JF4kZr1fJF1fZwb_yoW8GF4fpF 9xXrWkKr1rWw15XFsayay29Fn5WFyjgry5WFs7Ca1vvr1rAFy7Xr4xA34jqr4DJw1xZF1a krW7Wa4xGF4DtrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jUManUUUUU= X-Originating-IP: [58.213.111.46] X-CM-SenderInfo: xfkh0spkdqs5xldrqiyswou0bp/1tbi4w3prlpD41KEzAAAsJ X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Sun, 11 Feb 2018 03:07:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Sun, 11 Feb 2018 03:07:28 +0000 (UTC) for IP:'220.181.15.114' DOMAIN:'m15-114.126.com' HELO:'m15-114.126.com' FROM:'chen_han_xiao@126.com' RCPT:'' X-RedHat-Spam-Score: 1.99 * (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_PSBL, SPF_PASS, T_RP_MATCHES_RCVD) 220.181.15.114 m15-114.126.com 220.181.15.114 m15-114.126.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Chen Hanxiao Subject: [libvirt] [PATCH] qemu: don't leak in qemuGetDHCPInterfaces when failing to alloc 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: , MIME-Version: 1.0 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sun, 11 Feb 2018 03:08:43 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Chen Hanxiao We forgot to free alloced mem when failed to dup ifname or macaddr. Also use VIR_STEAL_PTR to simplify codes. Signed-off-by: Chen Hanxiao --- src/qemu/qemu_agent.c | 3 +-- src/qemu/qemu_driver.c | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 5d125c413..0f36054a6 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2190,8 +2190,7 @@ qemuAgentGetInterfaces(qemuAgentPtr mon, iface->naddrs =3D addrs_count; } =20 - *ifaces =3D ifaces_ret; - ifaces_ret =3D NULL; + VIR_STEAL_PTR(*ifaces, ifaces_ret); ret =3D ifaces_count; =20 cleanup: diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 978ecd4e0..60cdd237a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20569,10 +20569,10 @@ qemuGetDHCPInterfaces(virDomainPtr dom, goto error; =20 if (VIR_STRDUP(iface->name, vm->def->nets[i]->ifname) < 0) - goto cleanup; + goto error; =20 if (VIR_STRDUP(iface->hwaddr, macaddr) < 0) - goto cleanup; + goto error; } =20 for (j =3D 0; j < n_leases; j++) { @@ -20592,8 +20592,7 @@ qemuGetDHCPInterfaces(virDomainPtr dom, VIR_FREE(leases); } =20 - *ifaces =3D ifaces_ret; - ifaces_ret =3D NULL; + VIR_STEAL_PTR(*ifaces, ifaces_ret); rv =3D ifaces_count; =20 cleanup: --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list