Skip to content

Commit

Permalink
[NET]: Take RTNL when unregistering notifier
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Herbert Xu authored and David S. Miller committed Mar 25, 2006
1 parent 868d2c1 commit 9f51495
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 9f51495

Please sign in to comment.