bonding: Do not call free_netdev for already registered device.
authorPavel Emelyanov <xemul@openvz.org>
Sat, 3 May 2008 00:49:37 +0000 (17:49 -0700)
committerJeff Garzik <jgarzik@redhat.com>
Tue, 6 May 2008 16:01:27 +0000 (12:01 -0400)
If the call to bond_create_sysfs_entry in bond_create fails, the
proper rollback is to call unregister_netdevice, not free_netdev.
Otherwise - kernel BUG at net/core/dev.c:4057!

Checked with artificial failures injected into bond_create_sysfs_entry.

Pavel's original patch modified by Jay Vosburgh to move code around
for clarity (remove goto-hopping within the unwind block).

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
drivers/net/bonding/bond_main.c

index 6425603bc37976bebbec44283b37f4d377325c65..5509732d3f9d3e4cdfb3232befef3f71fc491a6d 100644 (file)
@@ -4936,7 +4936,9 @@ int bond_create(char *name, struct bond_params *params, struct bonding **newbond
        if (res < 0) {
                rtnl_lock();
                down_write(&bonding_rwsem);
-               goto out_bond;
+               bond_deinit(bond_dev);
+               unregister_netdevice(bond_dev);
+               goto out_rtnl;
        }
 
        return 0;