mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-08 22:15:21 +00:00
nodedev: Fix double unlock of the driver on udevEnumerateDevices failure
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 <eskultet@redhat.com>
This commit is contained in:
parent
aceb74cbd7
commit
159be14d9c
@ -1789,18 +1789,18 @@ nodeStateInitialize(bool privileged,
|
|||||||
nodeDeviceLock();
|
nodeDeviceLock();
|
||||||
|
|
||||||
if (!(driver->devs = virNodeDeviceObjListNew()))
|
if (!(driver->devs = virNodeDeviceObjListNew()))
|
||||||
goto cleanup;
|
goto unlock;
|
||||||
|
|
||||||
driver->nodeDeviceEventState = virObjectEventStateNew();
|
driver->nodeDeviceEventState = virObjectEventStateNew();
|
||||||
|
|
||||||
if (udevPCITranslateInit(privileged) < 0)
|
if (udevPCITranslateInit(privileged) < 0)
|
||||||
goto cleanup;
|
goto unlock;
|
||||||
|
|
||||||
udev = udev_new();
|
udev = udev_new();
|
||||||
if (!udev) {
|
if (!udev) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("failed to create udev context"));
|
_("failed to create udev context"));
|
||||||
goto cleanup;
|
goto unlock;
|
||||||
}
|
}
|
||||||
#if HAVE_UDEV_LOGGING
|
#if HAVE_UDEV_LOGGING
|
||||||
/* cast to get rid of missing-format-attribute warning */
|
/* cast to get rid of missing-format-attribute warning */
|
||||||
@ -1811,7 +1811,7 @@ nodeStateInitialize(bool privileged,
|
|||||||
if (priv->udev_monitor == NULL) {
|
if (priv->udev_monitor == NULL) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("udev_monitor_new_from_netlink returned NULL"));
|
_("udev_monitor_new_from_netlink returned NULL"));
|
||||||
goto cleanup;
|
goto unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
udev_monitor_enable_receiving(priv->udev_monitor);
|
udev_monitor_enable_receiving(priv->udev_monitor);
|
||||||
@ -1837,11 +1837,11 @@ nodeStateInitialize(bool privileged,
|
|||||||
VIR_EVENT_HANDLE_READABLE,
|
VIR_EVENT_HANDLE_READABLE,
|
||||||
udevEventHandleCallback, NULL, NULL);
|
udevEventHandleCallback, NULL, NULL);
|
||||||
if (priv->watch == -1)
|
if (priv->watch == -1)
|
||||||
goto cleanup;
|
goto unlock;
|
||||||
|
|
||||||
/* Create a fictional 'computer' device to root the device tree. */
|
/* Create a fictional 'computer' device to root the device tree. */
|
||||||
if (udevSetupSystemDev() != 0)
|
if (udevSetupSystemDev() != 0)
|
||||||
goto cleanup;
|
goto unlock;
|
||||||
|
|
||||||
nodeDeviceUnlock();
|
nodeDeviceUnlock();
|
||||||
|
|
||||||
@ -1852,9 +1852,12 @@ nodeStateInitialize(bool privileged,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
nodeDeviceUnlock();
|
|
||||||
nodeStateCleanup();
|
nodeStateCleanup();
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
unlock:
|
||||||
|
nodeDeviceUnlock();
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user