diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index 93ca28c226bacf60361bb263faf6a061d0d0f09c..c902e7d943f4af808b7ae69297c524408d623530 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -153,10 +153,15 @@ static int nodeNumOfDevices(virConnectPtr conn, int ndevs = 0; unsigned int i; - for (i = 0; i < driver->devs.count; i++) + nodeDeviceLock(driver); + for (i = 0; i < driver->devs.count; i++) { + virNodeDeviceObjLock(driver->devs.objs[i]); if ((cap == NULL) || dev_has_cap(driver->devs.objs[i], cap)) ++ndevs; + virNodeDeviceObjUnlock(driver->devs.objs[i]); + } + nodeDeviceUnlock(driver); return ndevs; }