[PATCH 1/3] udevRemoveOneDevice: Unlock node device obj upon return

Michal Privoznik mprivozn at redhat.com
Mon Apr 20 14:20:39 UTC 2020

When removing a node device object from the internal list the
udevRemoveOneDevice() function does plain unref over the object.
This is not sufficient. If there is another thread that's waiting
for the object lock it will wait forever.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
 src/node_device/node_device_udev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 3149de8321..0166a13b0f 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1244,7 +1244,7 @@ udevRemoveOneDevice(struct udev_device *device)
     VIR_DEBUG("Removing device '%s' with sysfs path '%s'",
               def->name, name);
     virNodeDeviceObjListRemove(driver->devs, obj);
-    virObjectUnref(obj);
+    virNodeDeviceObjEndAPI(&obj);
     virObjectEventStateQueue(driver->nodeDeviceEventState, event);
     return 0;

More information about the libvir-list mailing list