Re: [RFC PATCH v1 4/5] node_device_udev: Take lock if driver->privateData is modified

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

 



Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx>

On 4/3/24 16:03, Marc Hartmayer wrote:
Since @driver->privateData is modified take the lock.

Question: In theory we could take the udevEventData->mdevctlLock?

Isn't that protecting the access to the mdevctlMonitor?
On the first sight scheduleMdevctlUpdate does not directly make use of mdevctlMonitor.


Signed-off-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxx>
---
  src/node_device/node_device_udev.c | 15 +++++++++++----
  1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 8b4a62537c06..ca60f6f7db82 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1481,7 +1481,9 @@ udevRemoveOneDeviceSysPath(const char *path)
      virNodeDeviceObjEndAPI(&obj);
/* cannot check for mdev_types since they have already been removed */
-    scheduleMdevctlUpdate(driver->privateData, false);
+    VIR_WITH_OBJECT_LOCK_GUARD(driver->privateData) {
+        scheduleMdevctlUpdate(driver->privateData, false);
+    }
virObjectEventStateQueue(driver->nodeDeviceEventState, event);
      return 0;
@@ -1609,8 +1611,11 @@ udevAddOneDevice(struct udev_device *device)
      has_mdev_types = virNodeDeviceObjHasCap(obj, VIR_NODE_DEV_CAP_MDEV_TYPES);
      virNodeDeviceObjEndAPI(&obj);
- if (has_mdev_types)
-        scheduleMdevctlUpdate(driver->privateData, false);
+    if (has_mdev_types) {
+        VIR_WITH_OBJECT_LOCK_GUARD(driver->privateData) {
+            scheduleMdevctlUpdate(driver->privateData, false);
+        }
+    }
ret = 0; @@ -2232,7 +2237,9 @@ mdevctlEventHandleCallback(GFileMonitor *monitor G_GNUC_UNUSED,
       * configuration change, try to coalesce these changes by waiting for the
       * CHANGES_DONE_HINT event. As a fallback,  add a timeout to trigger the
       * signal if that event never comes */
-    scheduleMdevctlUpdate(priv, (event_type == G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT));
+    VIR_WITH_OBJECT_LOCK_GUARD(priv) {
+        scheduleMdevctlUpdate(priv, (event_type == G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT));
+    }
  }

--
Mit freundlichen Grüßen/Kind regards
   Boris Fiuczynski

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Wolfgang Wendt
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[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