projects
/
project
/
netifd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
device: protect device event broadcast against simultaneous deletions of multiple...
[project/netifd.git]
/
device.c
diff --git
a/device.c
b/device.c
index
97fb27f
..
9ef444e
100644
(file)
--- a/
device.c
+++ b/
device.c
@@
-183,14
+183,27
@@
static void __init dev_init(void)
static void __device_broadcast_event(struct list_head *head, enum device_event ev)
{
static void __device_broadcast_event(struct list_head *head, enum device_event ev)
{
- struct device_user *dep, *tmp;
+ struct device_user *dep;
+ static uint8_t idx[__DEV_EVENT_MAX];
+ bool found;
- list_for_each_entry_safe(dep, tmp, head, list) {
- if (!dep->cb)
-
continu
e;
+ idx[ev]++;
+ do {
+
found = fals
e;
- dep->cb(dep, ev);
- }
+ list_for_each_entry(dep, head, list) {
+ if (!dep->cb)
+ continue;
+
+ if (dep->ev_idx[ev] == idx[ev])
+ continue;
+
+ dep->cb(dep, ev);
+ dep->ev_idx[ev] = idx[ev];
+ found = true;
+ break;
+ }
+ } while (found);
}
void device_broadcast_event(struct device *dev, enum device_event ev)
}
void device_broadcast_event(struct device *dev, enum device_event ev)