richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
923a60
From 562bccced876d3bc0e9521ef31f6cc1e5cff9798 Mon Sep 17 00:00:00 2001
923a60
From: Franck Bui <fbui@suse.com>
923a60
Date: Wed, 30 Aug 2017 17:16:16 +0200
923a60
Subject: [PATCH] device: make sure to remove all device units sharing the same
923a60
 sysfs path (#6679)
923a60
923a60
When a device is unplugged all device units sharing the same sysfs path
923a60
pointing to that device are supposed to be removed.
923a60
923a60
However it didn't work since while iterating the device unit list containing
923a60
all the relevant units, each unit was removed during each iteration of
923a60
LIST_FOREACH. However LIST_FOREACH doesn't support this use case and
923a60
LIST_FOREACH_SAFE must be use instead.
923a60
923a60
(cherry picked from commit cc0df6cc35339976c367977dc292278a1939db0c)
923a60
923a60
Related: #1408916
923a60
---
923a60
 src/core/device.c | 4 ++--
923a60
 1 file changed, 2 insertions(+), 2 deletions(-)
923a60
923a60
diff --git a/src/core/device.c b/src/core/device.c
923a60
index 63a04bdd3c..2afa19f2b4 100644
923a60
--- a/src/core/device.c
923a60
+++ b/src/core/device.c
923a60
@@ -487,7 +487,7 @@ static void device_update_found_one(Device *d, bool add, DeviceFound found, bool
923a60
 }
923a60
 
923a60
 static int device_update_found_by_sysfs(Manager *m, const char *sysfs, bool add, DeviceFound found, bool now) {
923a60
-        Device *d, *l;
923a60
+        Device *d, *l, *n;
923a60
 
923a60
         assert(m);
923a60
         assert(sysfs);
923a60
@@ -496,7 +496,7 @@ static int device_update_found_by_sysfs(Manager *m, const char *sysfs, bool add,
923a60
                 return 0;
923a60
 
923a60
         l = hashmap_get(m->devices_by_sysfs, sysfs);
923a60
-        LIST_FOREACH(same_sysfs, d, l)
923a60
+        LIST_FOREACH_SAFE(same_sysfs, d, n, l)
923a60
                 device_update_found_one(d, add, found, now);
923a60
 
923a60
         return 0;