From nobody Sat May 4 18:07:59 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.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 1495798791324900.8360269206607; Fri, 26 May 2017 04:39:51 -0700 (PDT) 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 61EEE796E7; Fri, 26 May 2017 11:39:49 +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 164C97DFFB; Fri, 26 May 2017 11:39:49 +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 1A597180BAF2; Fri, 26 May 2017 11:39:48 +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 v4QBdV8g005686 for ; Fri, 26 May 2017 07:39:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 423F581B6E; Fri, 26 May 2017 11:39:31 +0000 (UTC) Received: from angien.brq.redhat.com (dhcp129-47.brq.redhat.com [10.34.129.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 93C2181B6C; Fri, 26 May 2017 11:39:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 61EEE796E7 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 61EEE796E7 From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 26 May 2017 13:39:24 +0200 Message-Id: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH] node: Don't return invalid pointers 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.25]); Fri, 26 May 2017 11:39:50 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Commit 4337bc57be introduced code that would in certain error paths unref the last reference of a pointer, but return it. Clear the pointers before returning them --- src/node_device/node_device_driver.c | 8 ++++++-- src/test/test_driver.c | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index ba3da6288..3a6eeaaae 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -241,8 +241,10 @@ nodeDeviceLookupByName(virConnectPtr conn, const char = *name) goto cleanup; if ((ret =3D virGetNodeDevice(conn, name))) { - if (VIR_STRDUP(ret->parent, obj->def->parent) < 0) + if (VIR_STRDUP(ret->parent, obj->def->parent) < 0) { virObjectUnref(ret); + ret =3D NULL; + } } cleanup: @@ -285,8 +287,10 @@ nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn, goto out; if ((dev =3D virGetNodeDevice(conn, obj->def->name= ))) { - if (VIR_STRDUP(dev->parent, obj->def->parent) = < 0) + if (VIR_STRDUP(dev->parent, obj->def->parent) = < 0) { virObjectUnref(dev); + dev =3D NULL; + } } virNodeDeviceObjUnlock(obj); goto out; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 2db3f7ddf..9330d9ea6 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -5331,8 +5331,10 @@ testNodeDeviceLookupByName(virConnectPtr conn, const= char *name) goto cleanup; if ((ret =3D virGetNodeDevice(conn, name))) { - if (VIR_STRDUP(ret->parent, obj->def->parent) < 0) + if (VIR_STRDUP(ret->parent, obj->def->parent) < 0) { virObjectUnref(ret); + ret =3D NULL; + } } cleanup: --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list