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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux