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

* Re: [PATCH] lib: notifier: allow unregistering notifier in notifier_call_chain
  2024-09-10  8:53 [PATCH] lib: notifier: allow unregistering notifier in notifier_call_chain Ahmad Fatoum
@ 2024-09-11  8:38 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-09-11  8:38 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Tue, 10 Sep 2024 10:53:31 +0200, Ahmad Fatoum wrote:
> It's possible for Linux notifiers to be removed from within the notifier
> callback. Allow the same within barebox to avoid subtle bugs.
> 
> 

Applied, thanks!

[1/1] lib: notifier: allow unregistering notifier in notifier_call_chain
      https://git.pengutronix.de/cgit/barebox/commit/?id=306e2fe5e6a1 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ 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