bonding: fix enslavement error unwinds

As part of:

commit c2edacf80e155ef54ae4774379d461b60896bc2e
Author: Jay Vosburgh <fubar@us.ibm.com>
Date: Mon Jul 9 10:42:47 2007 -0700

bonding / ipv6: no addrconf for slaves separately from master

two steps were rearranged in the enslavement process: netdev_set_master
is now before the call to dev_open to open the slave.

This patch updates the error cases and unwind process at the
end of bond_enslave to match the new order. Without this patch, it is
possible for the enslavement to fail, but leave the slave with IFF_SLAVE
set in its flags.

Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>

authored by Jay Vosburgh and committed by Jeff Garzik 569f0c4d ae68c398

+7 -7
+7 -7
drivers/net/bonding/bond_main.c
··· 1425 1425 res = netdev_set_master(slave_dev, bond_dev); 1426 1426 if (res) { 1427 1427 dprintk("Error %d calling netdev_set_master\n", res); 1428 - goto err_close; 1428 + goto err_restore_mac; 1429 1429 } 1430 1430 /* open the slave since the application closed it */ 1431 1431 res = dev_open(slave_dev); 1432 1432 if (res) { 1433 1433 dprintk("Openning slave %s failed\n", slave_dev->name); 1434 - goto err_restore_mac; 1434 + goto err_unset_master; 1435 1435 } 1436 1436 1437 1437 new_slave->dev = slave_dev; ··· 1444 1444 */ 1445 1445 res = bond_alb_init_slave(bond, new_slave); 1446 1446 if (res) { 1447 - goto err_unset_master; 1447 + goto err_close; 1448 1448 } 1449 1449 } 1450 1450 ··· 1619 1619 1620 1620 res = bond_create_slave_symlinks(bond_dev, slave_dev); 1621 1621 if (res) 1622 - goto err_unset_master; 1622 + goto err_close; 1623 1623 1624 1624 printk(KERN_INFO DRV_NAME 1625 1625 ": %s: enslaving %s as a%s interface with a%s link.\n", ··· 1631 1631 return 0; 1632 1632 1633 1633 /* Undo stages on error */ 1634 - err_unset_master: 1635 - netdev_set_master(slave_dev, NULL); 1636 - 1637 1634 err_close: 1638 1635 dev_close(slave_dev); 1636 + 1637 + err_unset_master: 1638 + netdev_set_master(slave_dev, NULL); 1639 1639 1640 1640 err_restore_mac: 1641 1641 if (!bond->params.fail_over_mac) {