]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[NET]: Take RTNL when unregistering notifier
authorHerbert Xu <herbert@gondor.apana.org.au>
Sat, 25 Mar 2006 09:24:25 +0000 (01:24 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 25 Mar 2006 09:24:25 +0000 (01:24 -0800)
The netdev notifier call chain is currently unregistered without taking
any locks outside the notifier system.  Because the notifier system itself
does not synchronise unregistration with respect to the calling of the
chain, we as its user need to do our own locking.

We are supposed to take the RTNL for all calls to netdev notifiers, so
taking the RTNL should be sufficient to protect it.

The registration path in dev.c already takes the RTNL so it's OK.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/dev.c

index 08dec6eb922bc6c971f952c4c396bf23e7c7d292..e0489ca731c57f17dda1ce30cfc7747098c4e221 100644 (file)
@@ -977,7 +977,12 @@ int register_netdevice_notifier(struct notifier_block *nb)
 
 int unregister_netdevice_notifier(struct notifier_block *nb)
 {
-       return notifier_chain_unregister(&netdev_chain, nb);
+       int err;
+
+       rtnl_lock();
+       err = notifier_chain_unregister(&netdev_chain, nb);
+       rtnl_unlock();
+       return err;
 }
 
 /**