anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

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

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