teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame 0024-device-make-sure-to-remove-all-device-units-sharing-.patch

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