mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
nodedev: Lock @priv sooner
The nodedev driver private data object @priv is created by calling udevEventDataNew(). After that, driver->privateData pointer is set to the freshly allocated object and only a few lines after all of this the object is locked. Technically it is safe because there should not be any other thread at this point, but defensive style of programming says it's better if the object is locked before driver's privateData is set. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
9cfcc296fe
commit
3d3435e395
@ -2212,21 +2212,21 @@ nodeStateInitialize(bool privileged,
|
||||
!(priv = udevEventDataNew()))
|
||||
goto cleanup;
|
||||
|
||||
virObjectLock(priv);
|
||||
|
||||
driver->privateData = priv;
|
||||
driver->nodeDeviceEventState = virObjectEventStateNew();
|
||||
|
||||
if (udevPCITranslateInit(privileged) < 0)
|
||||
goto cleanup;
|
||||
goto unlock;
|
||||
|
||||
udev = udev_new();
|
||||
if (!udev) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("failed to create udev context"));
|
||||
goto cleanup;
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
virObjectLock(priv);
|
||||
|
||||
priv->udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
|
||||
if (!priv->udev_monitor) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
|
Loading…
x
Reference in New Issue
Block a user