bonding: Do not call free_netdev for already registered device.

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>

authored by Pavel Emelyanov and committed by Jeff Garzik 822973ba 9d1045ad

+3 -1
+3 -1
drivers/net/bonding/bond_main.c
··· 4936 if (res < 0) { 4937 rtnl_lock(); 4938 down_write(&bonding_rwsem); 4939 - goto out_bond; 4940 } 4941 4942 return 0;
··· 4936 if (res < 0) { 4937 rtnl_lock(); 4938 down_write(&bonding_rwsem); 4939 + bond_deinit(bond_dev); 4940 + unregister_netdevice(bond_dev); 4941 + goto out_rtnl; 4942 } 4943 4944 return 0;