From nobody Wed May 1 23:57:14 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1501058787420569.3908961078284; Wed, 26 Jul 2017 01:46:27 -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 91A3FC0B2C46; Wed, 26 Jul 2017 08:46:24 +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 620DB65EB6; Wed, 26 Jul 2017 08:46:22 +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 6BE284BB79; Wed, 26 Jul 2017 08:46:19 +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 v6Q8jId1014801 for ; Wed, 26 Jul 2017 04:45:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id B74A66FE45; Wed, 26 Jul 2017 08:45:18 +0000 (UTC) Received: from beluga.usersys.redhat.com (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 129AF6FB77; Wed, 26 Jul 2017 08:45:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 91A3FC0B2C46 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com From: Erik Skultety To: libvir-list@redhat.com Date: Wed, 26 Jul 2017 10:45:11 +0200 Message-Id: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH] nodedev: Fix double unlock of the driver on udevEnumerateDevices failure 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 26 Jul 2017 08:46:25 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Commit @4cb719b2dc moved the driver locks around since these have become unnecessary at spots where the code handles now self-lockable object list, but missed the possible double unlock if udevEnumerateDevices fails, because at that point the driver lock had been already dropped. Signed-off-by: Erik Skultety --- src/node_device/node_device_udev.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 4762f1969..4c35fd5c9 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1789,18 +1789,18 @@ nodeStateInitialize(bool privileged, nodeDeviceLock(); =20 if (!(driver->devs =3D virNodeDeviceObjListNew())) - goto cleanup; + goto unlock; =20 driver->nodeDeviceEventState =3D virObjectEventStateNew(); =20 if (udevPCITranslateInit(privileged) < 0) - goto cleanup; + goto unlock; =20 udev =3D udev_new(); if (!udev) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to create udev context")); - goto cleanup; + goto unlock; } #if HAVE_UDEV_LOGGING /* cast to get rid of missing-format-attribute warning */ @@ -1811,7 +1811,7 @@ nodeStateInitialize(bool privileged, if (priv->udev_monitor =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("udev_monitor_new_from_netlink returned NULL")); - goto cleanup; + goto unlock; } =20 udev_monitor_enable_receiving(priv->udev_monitor); @@ -1837,11 +1837,11 @@ nodeStateInitialize(bool privileged, VIR_EVENT_HANDLE_READABLE, udevEventHandleCallback, NULL, NULL); if (priv->watch =3D=3D -1) - goto cleanup; + goto unlock; =20 /* Create a fictional 'computer' device to root the device tree. */ if (udevSetupSystemDev() !=3D 0) - goto cleanup; + goto unlock; =20 nodeDeviceUnlock(); =20 @@ -1852,9 +1852,12 @@ nodeStateInitialize(bool privileged, return 0; =20 cleanup: - nodeDeviceUnlock(); nodeStateCleanup(); return -1; + + unlock: + nodeDeviceUnlock(); + goto cleanup; } =20 =20 --=20 2.13.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list