From nobody Tue Feb 10 08:31:14 2026 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1531130187988458.9229931030595; Mon, 9 Jul 2018 02:56:27 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A98AE30820D1; Mon, 9 Jul 2018 09:56:25 +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 00BDA1001918; Mon, 9 Jul 2018 09:56:24 +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 53E724A465; Mon, 9 Jul 2018 09:56:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w699uK09001024 for ; Mon, 9 Jul 2018 05:56:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4A03E111E3EB; Mon, 9 Jul 2018 09:56:20 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2E02111E3E8 for ; Mon, 9 Jul 2018 09:56:19 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 9 Jul 2018 11:56:09 +0200 Message-Id: <9861f561a2950b3ce424b8a1770a2619186fc251.1531129992.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/6] qemuBuildSCSIiSCSIHostdevDrvStr: Don't leak @netsource and @srcprops 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 09 Jul 2018 09:56:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" After 6b770f9a3bdabb1 both @netsource and @srcprops are leaked because of early return introduced in the commit. =3D=3D1812=3D=3D 644 bytes in 4 blocks are definitely lost in loss record 8= 35 of 885 =3D=3D1812=3D=3D at 0x4C2F12F: realloc (vg_replace_malloc.c:785) =3D=3D1812=3D=3D by 0x8846393: xmlSaveUriRealloc (in /usr/lib64/libxml2.= so.2.9.8) =3D=3D1812=3D=3D by 0x8846B1C: xmlSaveUri (in /usr/lib64/libxml2.so.2.9.= 8) =3D=3D1812=3D=3D by 0x5DDA619: virURIFormat (viruri.c:256) =3D=3D1812=3D=3D by 0x56E941B: qemuBuildNetworkDriveURI (qemu_command.c:= 781) =3D=3D1812=3D=3D by 0x56E979A: qemuBuildNetworkDriveStr (qemu_command.c:= 859) =3D=3D1812=3D=3D by 0x56F3A0B: qemuBuildSCSIiSCSIHostdevDrvStr (qemu_com= mand.c:4664) =3D=3D1812=3D=3D by 0x56F3D1F: qemuBuildSCSIHostdevDrvStr (qemu_command.= c:4732) =3D=3D1812=3D=3D by 0x56F57F7: qemuBuildHostdevCommandLine (qemu_command= .c:5337) =3D=3D1812=3D=3D by 0x570303A: qemuBuildCommandLine (qemu_command.c:1037= 6) =3D=3D1812=3D=3D by 0x57604EE: qemuProcessCreatePretendCmd (qemu_process= .c:6649) =3D=3D1812=3D=3D by 0x11352A: testCompareXMLToArgv (qemuxml2argvtest.c:5= 66) Signed-off-by: Michal Privoznik --- src/qemu/qemu_command.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 32eb59b6ab..86970f3d91 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4644,8 +4644,8 @@ static char * qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, virQEMUCapsPtr qemuCaps) { + char *ret =3D NULL; virBuffer buf =3D VIR_BUFFER_INITIALIZER; - char *netsource =3D NULL; virJSONValuePtr srcprops =3D NULL; virDomainHostdevSubsysSCSIPtr scsisrc =3D &dev->source.subsys.u.scsi; @@ -4672,13 +4672,13 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDef= Ptr dev, if (virBufferCheckError(&buf) < 0) goto cleanup; =20 - return virBufferContentAndReset(&buf); + ret =3D virBufferContentAndReset(&buf); =20 cleanup: VIR_FREE(netsource); virJSONValueFree(srcprops); virBufferFreeAndReset(&buf); - return NULL; + return ret; } =20 char * --=20 2.16.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list