Skip to content

Commit 8327070

Browse files
congwangdavem330
authored andcommitted
bonding: fix a potential double-unregister
When we tear down a network namespace, we unregister all the netdevices within it. So we may queue a slave device and a bonding device together in the same unregister queue. If the only slave device is non-ethernet, it would automatically unregister the bonding device as well. Thus, we may end up unregistering the bonding device twice. Workaround this special case by checking reg_state. Fixes: 9b5e383 ("net: Introduce unregister_netdevice_many()") Reported-by: [email protected] Cc: Eric Dumazet <[email protected]> Cc: Andy Gospodarek <[email protected]> Cc: Jay Vosburgh <[email protected]> Signed-off-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 81dbf21 commit 8327070

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2207,7 +2207,8 @@ static int bond_release_and_destroy(struct net_device *bond_dev,
22072207
int ret;
22082208

22092209
ret = __bond_release_one(bond_dev, slave_dev, false, true);
2210-
if (ret == 0 && !bond_has_slaves(bond)) {
2210+
if (ret == 0 && !bond_has_slaves(bond) &&
2211+
bond_dev->reg_state != NETREG_UNREGISTERING) {
22112212
bond_dev->priv_flags |= IFF_DISABLE_NETPOLL;
22122213
netdev_info(bond_dev, "Destroying bond\n");
22132214
bond_remove_proc_entry(bond);

0 commit comments

Comments
 (0)