diff options
author | Jay Vosburgh <fubar@us.ibm.com> | 2007-06-19 14:12:12 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-06-20 19:12:41 -0400 |
commit | 3201e656ce56ed02e9501906c18ffe16ae350a52 (patch) | |
tree | 8dbe0df57ffb7afd7fe1aac65fcd0ae0600870f0 /drivers | |
parent | 3a2c892daaf54b31a70785c2821771e8094188ed (diff) |
bonding: Fix use after free in unregister path
The following patch (based on a patch from Stephen Hemminger
<shemminger@linux-foundation.org>) removes use after free conditions in
the unregister path for the bonding master. Without this patch, an
operation of the form "echo -bond0 > /sys/class/net/bonding_masters"
would trigger a NULL pointer dereference in sysfs. I was not able to
induce the failure with the non-sysfs code path, but for consistency I
updated that code as well.
I also did some testing of the bonding /proc file being open
while the bond is being deleted, and didn't see any problems there.
Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/bonding/bond_main.c | 2 | ||||
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 223517dcbcfd..6287ffbda7f7 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -4345,8 +4345,8 @@ static void bond_free_all(void) | |||
4345 | bond_mc_list_destroy(bond); | 4345 | bond_mc_list_destroy(bond); |
4346 | /* Release the bonded slaves */ | 4346 | /* Release the bonded slaves */ |
4347 | bond_release_all(bond_dev); | 4347 | bond_release_all(bond_dev); |
4348 | unregister_netdevice(bond_dev); | ||
4349 | bond_deinit(bond_dev); | 4348 | bond_deinit(bond_dev); |
4349 | unregister_netdevice(bond_dev); | ||
4350 | } | 4350 | } |
4351 | 4351 | ||
4352 | #ifdef CONFIG_PROC_FS | 4352 | #ifdef CONFIG_PROC_FS |
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index a122baa5c7bb..60cccf2aa959 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -164,9 +164,9 @@ static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t | |||
164 | printk(KERN_INFO DRV_NAME | 164 | printk(KERN_INFO DRV_NAME |
165 | ": %s is being deleted...\n", | 165 | ": %s is being deleted...\n", |
166 | bond->dev->name); | 166 | bond->dev->name); |
167 | unregister_netdevice(bond->dev); | ||
168 | bond_deinit(bond->dev); | 167 | bond_deinit(bond->dev); |
169 | bond_destroy_sysfs_entry(bond); | 168 | bond_destroy_sysfs_entry(bond); |
169 | unregister_netdevice(bond->dev); | ||
170 | rtnl_unlock(); | 170 | rtnl_unlock(); |
171 | goto out; | 171 | goto out; |
172 | } | 172 | } |