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

Erik Skultety posted 7 patches 8 years, 2 months ago
There is a newer version of this series
[libvirt] [PATCH v4 2/7] nodedev: udev: Lock the driver in udevEventCheckMonitorFd
Posted by Erik Skultety 8 years, 2 months ago
The udev monitor is not an immutable resource, so better protect every
access to it.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
---
 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@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v4 2/7] nodedev: udev: Lock the driver in udevEventCheckMonitorFd
Posted by John Ferlan 8 years, 2 months ago

On 09/18/2017 12:34 PM, Erik Skultety wrote:
> The udev monitor is not an immutable resource, so better protect every
> access to it.
> 
> Signed-off-by: Erik Skultety <eskultet@redhat.com>
> ---
>  src/node_device/node_device_udev.c | 3 +++
>  1 file changed, 3 insertions(+)
> 

Of course this one will have the obvious adjustment from merge conflict
of the previous patch...


Reviewed-by: John Ferlan <jferlan@redhat.com>

John

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