From nobody Sat May 4 09:38:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1487618192017806.1187254139024; Mon, 20 Feb 2017 11:16:32 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1KJDHT9008033; Mon, 20 Feb 2017 14:13:17 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1KJCoTR023319 for ; Mon, 20 Feb 2017 14:12:50 -0500 Received: from localhost.localdomain.com (ovpn-116-126.phx2.redhat.com [10.3.116.126]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1KJCnX4014611 for ; Mon, 20 Feb 2017 14:12:50 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Mon, 20 Feb 2017 14:12:45 -0500 Message-Id: <20170220191246.14267-2-jferlan@redhat.com> In-Reply-To: <20170220191246.14267-1-jferlan@redhat.com> References: <20170220191246.14267-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] conf: Cleanup matchFCHostToSCSIHost 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than the inlined VIR_FREE's, use a cleanup: label... Fixes an issue introduced by 03346def where @name was free'd before usage in a virAsprintf to format scsi_host_name. Signed-off-by: John Ferlan --- src/conf/storage_conf.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 0e9a51f..a52eeba 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -2341,6 +2341,7 @@ matchFCHostToSCSIHost(virConnectPtr conn, virStoragePoolSourceAdapter fc_adapter, unsigned int scsi_hostnum) { + bool ret =3D false; char *name =3D NULL; char *scsi_host_name =3D NULL; char *parent_name =3D NULL; @@ -2362,10 +2363,9 @@ matchFCHostToSCSIHost(virConnectPtr conn, * matches our scsi_hostnum */ if (virStorageIsSameHostnum(name, scsi_hostnum)) { - VIR_FREE(name); - return true; + ret =3D true; + goto cleanup; } - VIR_FREE(name); =20 /* We weren't provided a parent, so we have to query the node * device driver in order to ascertain the parent of the vHBA. @@ -2373,23 +2373,18 @@ matchFCHostToSCSIHost(virConnectPtr conn, * have a match. */ if (conn && !fc_adapter.data.fchost.parent) { - if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0) { - VIR_FREE(name); - return false; - } + if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0) + goto cleanup; if ((parent_name =3D virNodeDeviceGetParentName(conn, scsi_host_name))= ) { - VIR_FREE(scsi_host_name); if (virStorageIsSameHostnum(parent_name, scsi_hostnum)) { - VIR_FREE(parent_name); - return true; + ret =3D true; + goto cleanup; } - VIR_FREE(parent_name); } else { /* Throw away the error and fall through */ virResetLastError(); VIR_DEBUG("Could not determine parent vHBA"); - VIR_FREE(scsi_host_name); } } } @@ -2401,7 +2396,12 @@ matchFCHostToSCSIHost(virConnectPtr conn, * conflict with an existing scsi_host definition, but there's no * way to know that now. */ - return false; + + cleanup: + VIR_FREE(name); + VIR_FREE(parent_name); + VIR_FREE(scsi_host_name); + return ret; } =20 static bool --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 09:38:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; envelope-from=libvir-list-bounces@redhat.com; helo=mx3-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mx.zohomail.com with SMTPS id 1487618190590444.4307354628712; Mon, 20 Feb 2017 11:16:30 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1KJCpxQ000926; Mon, 20 Feb 2017 14:12:52 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1KJCogB023324 for ; Mon, 20 Feb 2017 14:12:50 -0500 Received: from localhost.localdomain.com (ovpn-116-126.phx2.redhat.com [10.3.116.126]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1KJCnX5014611 for ; Mon, 20 Feb 2017 14:12:50 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Mon, 20 Feb 2017 14:12:46 -0500 Message-Id: <20170220191246.14267-3-jferlan@redhat.com> In-Reply-To: <20170220191246.14267-1-jferlan@redhat.com> References: <20170220191246.14267-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] conf: Fix leak in virNodeDeviceObjListExport 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Fix a leak introduced by 4337bc57b when VIR_STRDUP'g the parent. Signed-off-by: John Ferlan --- src/conf/node_device_conf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 1c81b48..c802840 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -2288,6 +2288,7 @@ virNodeDeviceObjListExport(virConnectPtr conn, if (devices) { if (!(device =3D virGetNodeDevice(conn, devobj->def->name)= ) || VIR_STRDUP(device->parent, devobj->def->parent) < 0) { + virObjectUnref(device); virNodeDeviceObjUnlock(devobj); goto cleanup; } --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list