[ 03/23] [Suspend2] Allow a notifier to remove itself from the notifier list.

From: Nigel Cunningham
Date: Wed Jan 25 2006 - 22:53:09 EST



This is Christoph Lameter's original patch, posted to LKML some time ago,
but as yet unmerged.

Allow a notifier to remove itself from the notifier list.

If the next pointer is retrieved before notifier_call then the notifier can
remove itself from the chain.

Signed-off-by: Christoph Lameter <christoph@xxxxxxxxxxx>
Signed-off-by: Nigel Cunningham <nigel@xxxxxxxxxxxx>

kernel/sys.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/kernel/sys.c b/kernel/sys.c
index d09cac2..46455fa 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -174,15 +174,18 @@ int __kprobes notifier_call_chain(struct
{
int ret=NOTIFY_DONE;
struct notifier_block *nb = *n;
+ struct notifier_block *next;

while(nb)
{
- ret=nb->notifier_call(nb,val,v);
+ /* Determining next here allows the notifier to unregister itself */
+ next = nb->next;
+ ret = nb->notifier_call(nb,val,v);
if(ret&NOTIFY_STOP_MASK)
{
return ret;
}
- nb=nb->next;
+ nb = next;
}
return ret;
}

--
Nigel Cunningham nigel at suspend2 dot net
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/