[BONDING]: Fix resource use after free
authorJay Vosburgh <fubar@us.ibm.com>
Wed, 14 Nov 2007 05:16:29 +0000 (21:16 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 14 Nov 2007 05:16:29 +0000 (21:16 -0800)
Fix bond_destroy and bond_free_all to not reference the struct
net_device after calling unregister_netdevice.

Bug and offending change reported by Moni Shoua <monis@voltaire.com>

Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/bonding/bond_main.c

index a198404a3e36d3a9781b7efa653ced731acdb4e2..423298c84a1da7a9f36668a15e1178d30ee163a5 100644 (file)
@@ -1847,9 +1847,9 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
 */
 void bond_destroy(struct bonding *bond)
 {
-       unregister_netdevice(bond->dev);
        bond_deinit(bond->dev);
        bond_destroy_sysfs_entry(bond);
+       unregister_netdevice(bond->dev);
 }
 
 /*
@@ -4475,8 +4475,8 @@ static void bond_free_all(void)
                bond_mc_list_destroy(bond);
                /* Release the bonded slaves */
                bond_release_all(bond_dev);
-               unregister_netdevice(bond_dev);
                bond_deinit(bond_dev);
+               unregister_netdevice(bond_dev);
        }
 
 #ifdef CONFIG_PROC_FS