diff options
author | Krishna Kumar <krkumar2@in.ibm.com> | 2009-12-08 17:26:02 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-12-11 18:11:45 -0500 |
commit | e93737b0f0159a61772894943199fd3b6f315641 (patch) | |
tree | feaa10bd2419f2a1bad89bcf4880bc8399339873 /net/core | |
parent | bbb84619c378414118fd4f1778125cd246c71e53 (diff) |
net: Handle NETREG_UNINITIALIZED devices correctly
Fix two problems:
1. If unregister_netdevice_many() is called with both registered
and unregistered devices, rollback_registered_many() bails out
when it reaches the first unregistered device. The processing
of the prior registered devices is unfinished, and the
remaining devices are skipped, and possible registered netdev's
are leaked/unregistered.
2. System hangs or panics depending on how the devices are passed,
since when netdev_run_todo() runs, some devices were not fully
processed.
Tested by passing intermingled unregistered and registered vlan
devices to unregister_netdevice_many() as follows:
1. dev, fake_dev1, fake_dev2: hangs in run_todo
("unregister_netdevice: waiting for eth1.100 to become
free. Usage count = 1")
2. fake_dev1, dev, fake_dev2: failure during de-registration
and next registration, followed by a vlan driver Oops
during subsequent registration.
Confirmed that the patch fixes both cases.
Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/dev.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index c36a17aafcf3..6fe7d739e59b 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -4771,21 +4771,23 @@ static void net_set_todo(struct net_device *dev) | |||
4771 | 4771 | ||
4772 | static void rollback_registered_many(struct list_head *head) | 4772 | static void rollback_registered_many(struct list_head *head) |
4773 | { | 4773 | { |
4774 | struct net_device *dev; | 4774 | struct net_device *dev, *tmp; |
4775 | 4775 | ||
4776 | BUG_ON(dev_boot_phase); | 4776 | BUG_ON(dev_boot_phase); |
4777 | ASSERT_RTNL(); | 4777 | ASSERT_RTNL(); |
4778 | 4778 | ||
4779 | list_for_each_entry(dev, head, unreg_list) { | 4779 | list_for_each_entry_safe(dev, tmp, head, unreg_list) { |
4780 | /* Some devices call without registering | 4780 | /* Some devices call without registering |
4781 | * for initialization unwind. | 4781 | * for initialization unwind. Remove those |
4782 | * devices and proceed with the remaining. | ||
4782 | */ | 4783 | */ |
4783 | if (dev->reg_state == NETREG_UNINITIALIZED) { | 4784 | if (dev->reg_state == NETREG_UNINITIALIZED) { |
4784 | pr_debug("unregister_netdevice: device %s/%p never " | 4785 | pr_debug("unregister_netdevice: device %s/%p never " |
4785 | "was registered\n", dev->name, dev); | 4786 | "was registered\n", dev->name, dev); |
4786 | 4787 | ||
4787 | WARN_ON(1); | 4788 | WARN_ON(1); |
4788 | return; | 4789 | list_del(&dev->unreg_list); |
4790 | continue; | ||
4789 | } | 4791 | } |
4790 | 4792 | ||
4791 | BUG_ON(dev->reg_state != NETREG_REGISTERED); | 4793 | BUG_ON(dev->reg_state != NETREG_REGISTERED); |