Allow a notifier to remove itself from the notifier list.

This is done by retrieving the pointer to the next notifier from the list 
before the
notifier call. If a notifier removes itself in the current kernel then the 
pointer to the current notifier is invalid and notifier_call_chain 
will fail.

Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]>

Index: linux-2.6.13-rc3/kernel/sys.c
===================================================================
--- linux-2.6.13-rc3.orig/kernel/sys.c  2005-07-12 21:46:46.000000000 -0700
+++ linux-2.6.13-rc3/kernel/sys.c       2005-07-28 11:26:00.000000000 -0700
@@ -171,15 +171,18 @@
 {
        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;
 }
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to