[PATCH] lib: notifier: allow unregistering notifier in notifier_call_chain

Ahmad Fatoum a.fatoum at pengutronix.de
Tue Sep 10 01:53:31 PDT 2024


It's possible for Linux notifiers to be removed from within the notifier
callback. Allow the same within barebox to avoid subtle bugs.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 lib/notifier.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/notifier.c b/lib/notifier.c
index c55ec22f94c2..3ca557f76df2 100644
--- a/lib/notifier.c
+++ b/lib/notifier.c
@@ -18,9 +18,9 @@ int notifier_chain_unregister(struct notifier_head *nh, struct notifier_block *n
 
 int notifier_call_chain(struct notifier_head *nh, unsigned long val, void *v)
 {
-	struct notifier_block *entry;
+	struct notifier_block *entry, *tmp;
 
-	list_for_each_entry(entry, &nh->blocks, list)
+	list_for_each_entry_safe(entry, tmp, &nh->blocks, list)
 		entry->notifier_call(entry, val, v);
 
 	return 0;
-- 
2.39.2




More information about the barebox mailing list