]> xenbits.xensource.com Git - libvirt.git/commitdiff
virnodedeviceobj: Don't unlock virNodeDeviceObj in virNodeDeviceObjListRemove()
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 1 Feb 2022 14:40:23 +0000 (15:40 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 3 Feb 2022 08:37:44 +0000 (09:37 +0100)
When virNodeDeviceObjListRemove() is called, the passed
virNodeDeviceObj is removed from internal list of node devices
and then unrefed and unlocked. While the former is warranted (the
object was refed at the beginning of the function) the unlock is
not. In fact, it's wrong from conceptual POV. We still want
threads working on the object tu mutually exclude each other.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/conf/virnodedeviceobj.c
src/test/test_driver.c

index 2e4ef2df3c200788c659320038dc766bf50659e5..7a560349d4ccfe6fc9c4e48be4c9c8d7d55a60c2 100644 (file)
@@ -524,7 +524,7 @@ virNodeDeviceObjListRemove(virNodeDeviceObjList *devs,
     virObjectRWLockWrite(devs);
     virObjectLock(obj);
     virNodeDeviceObjListRemoveLocked(devs, obj);
-    virNodeDeviceObjEndAPI(&obj);
+    virObjectUnref(obj);
     virObjectRWUnlock(devs);
 }
 
index 9e1fc659724d3898c0d0f7ba4212550cc4d5fb99..f900123941c7b9a4d82b273172d57b5c97053567 100644 (file)
@@ -6810,7 +6810,7 @@ testDestroyVport(testDriver *privconn,
                                            0);
 
     virNodeDeviceObjListRemove(privconn->devs, obj);
-    virObjectUnref(obj);
+    virNodeDeviceObjEndAPI(&obj);
 
     virObjectEventStateQueue(privconn->eventState, event);
     return 0;
@@ -7797,8 +7797,6 @@ testNodeDeviceDestroy(virNodeDevicePtr dev)
 
     virObjectLock(obj);
     virNodeDeviceObjListRemove(driver->devs, obj);
-    virObjectUnref(obj);
-    obj = NULL;
 
  cleanup:
     virNodeDeviceObjEndAPI(&obj);