]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
[BRIDGE]: fix locking and memory leak in br_add_bridge
authorJiri Benc <jbenc@suse.cz>
Mon, 5 Jun 2006 23:39:34 +0000 (16:39 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 5 Jun 2006 23:39:34 +0000 (16:39 -0700)
There are several bugs in error handling in br_add_bridge:
- when dev_alloc_name fails, allocated net_device is not freed
- unregister_netdev is called when rtnl lock is held
- free_netdev is called before netdev_run_todo has a chance to be run after
  unregistering net_device

Signed-off-by: Jiri Benc <jbenc@suse.cz>
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/bridge/br_if.c

index ad1c7af65ec8dcb944b59d2310df3c9ec539805d..f5d47bf4f9675cac0b7ead68f1c25f92ba5f785c 100644 (file)
@@ -300,25 +300,20 @@ int br_add_bridge(const char *name)
        rtnl_lock();
        if (strchr(dev->name, '%')) {
                ret = dev_alloc_name(dev, dev->name);
-               if (ret < 0)
-                       goto err1;
+               if (ret < 0) {
+                       free_netdev(dev);
+                       goto out;
+               }
        }
 
        ret = register_netdevice(dev);
        if (ret)
-               goto err2;
+               goto out;
 
        ret = br_sysfs_addbr(dev);
        if (ret)
-               goto err3;
-       rtnl_unlock();
-       return 0;
-
- err3:
-       unregister_netdev(dev);
- err2:
-       free_netdev(dev);
- err1:
+               unregister_netdevice(dev);
+ out:
        rtnl_unlock();
        return ret;
 }