mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] lib: notifier: allow unregistering notifier in notifier_call_chain
@ 2024-09-10  8:53 Ahmad Fatoum
  2024-09-11  8:38 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2024-09-10  8:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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@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




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-09-11  8:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-10  8:53 [PATCH] lib: notifier: allow unregistering notifier in notifier_call_chain Ahmad Fatoum
2024-09-11  8:38 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox