[PATCH v4 2/7] nodedev: udev: Lock the driver in udevEventCheckMonitorFd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The udev monitor is not an immutable resource, so better protect every
access to it.

Signed-off-by: Erik Skultety <eskultet@xxxxxxxxxx>
---
 src/node_device/node_device_udev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index fe21ad7df..6c7f887ed 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1615,6 +1615,7 @@ udevHandleOneDevice(struct udev_device *device)
 }
 
 
+/* the caller must be holding the driver lock prior to calling this function */
 static bool
 udevEventCheckMonitorFD(struct udev_monitor *udev_monitor,
                         int fd)
@@ -1653,6 +1654,7 @@ udevEventHandleCallback(int watch ATTRIBUTE_UNUSED,
     struct udev_device *device = NULL;
     struct udev_monitor *udev_monitor = NULL;
 
+    nodeDeviceLock();
     udev_monitor = DRV_STATE_UDEV_MONITOR(driver);
 
     if (!udevEventCheckMonitorFD(udev_monitor, fd)) {
@@ -1661,6 +1663,7 @@ udevEventHandleCallback(int watch ATTRIBUTE_UNUSED,
     }
 
     device = udev_monitor_receive_device(udev_monitor);
+    nodeDeviceUnlock();
 
     if (!device) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-- 
2.13.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux