anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0530-device-make-sure-to-remove-all-device-units-sharing-.patch

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