diff options
author | nikolay@redhat.com <nikolay@redhat.com> | 2013-04-18 03:33:36 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-04-19 17:48:19 -0400 |
commit | 3c5913b53fefc9d9e15a2d0f93042766658d9f3f (patch) | |
tree | 772296984f4e7f56b8cc0aa4949cfee3582ddc8b /drivers/net/bonding | |
parent | a506e7b479e1215c230e4b87fedc246cf748537f (diff) |
bonding: primary_slave & curr_active_slave are not cleaned on enslave failure
On enslave failure primary_slave can point to new_slave which is to be
freed, and the same applies to curr_active_slave. So check if this is
the case and clean up properly after err_detach because that's the first
error code path after they're set.
Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r-- | drivers/net/bonding/bond_main.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index dd67c49070d7..1137d5eac450 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -1909,7 +1909,17 @@ err_detach: | |||
1909 | bond_del_vlans_from_slave(bond, slave_dev); | 1909 | bond_del_vlans_from_slave(bond, slave_dev); |
1910 | write_lock_bh(&bond->lock); | 1910 | write_lock_bh(&bond->lock); |
1911 | bond_detach_slave(bond, new_slave); | 1911 | bond_detach_slave(bond, new_slave); |
1912 | if (bond->primary_slave == new_slave) | ||
1913 | bond->primary_slave = NULL; | ||
1912 | write_unlock_bh(&bond->lock); | 1914 | write_unlock_bh(&bond->lock); |
1915 | if (bond->curr_active_slave == new_slave) { | ||
1916 | read_lock(&bond->lock); | ||
1917 | write_lock_bh(&bond->curr_slave_lock); | ||
1918 | bond_change_active_slave(bond, NULL); | ||
1919 | bond_select_active_slave(bond); | ||
1920 | write_unlock_bh(&bond->curr_slave_lock); | ||
1921 | read_unlock(&bond->lock); | ||
1922 | } | ||
1913 | 1923 | ||
1914 | err_close: | 1924 | err_close: |
1915 | slave_dev->priv_flags &= ~IFF_BONDING; | 1925 | slave_dev->priv_flags &= ~IFF_BONDING; |