Skip to content

Commit

Permalink
net: dev_close() should check IFF_UP
Browse files Browse the repository at this point in the history
Commit 4434572 (factorize sync-rcu call in
unregister_netdevice_many) mistakenly removed one test from dev_close()

Following actions trigger a BUG :

modprobe bonding
modprobe dummy
ifconfig bond0 up
ifenslave bond0 dummy0
rmmod dummy

dev_close() must not close a non IFF_UP device.

With help from Frank Blaschka and Einar EL Lueck

Reported-by: Frank Blaschka <blaschka@linux.vnet.ibm.com>
Reported-by: Einar EL Lueck <ELELUECK@de.ibm.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed May 10, 2011
1 parent 55aee10 commit e14a599
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1284,11 +1284,13 @@ static int dev_close_many(struct list_head *head)
*/
int dev_close(struct net_device *dev)
{
LIST_HEAD(single);
if (dev->flags & IFF_UP) {
LIST_HEAD(single);

list_add(&dev->unreg_list, &single);
dev_close_many(&single);
list_del(&single);
list_add(&dev->unreg_list, &single);
dev_close_many(&single);
list_del(&single);
}
return 0;
}
EXPORT_SYMBOL(dev_close);
Expand Down

0 comments on commit e14a599

Please sign in to comment.