netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Aleksandrov <nikolay@redhat.com>
To: netdev@vger.kernel.org
Cc: andy@greyhouse.net, fubar@us.ibm.com, davem@davemloft.net
Subject: [PATCHv3 3/5] bonding: primary_slave & curr_active_slave are not cleaned on enslave failure
Date: Thu, 18 Apr 2013 19:33:36 +0200	[thread overview]
Message-ID: <1366306418-3661-4-git-send-email-nikolay@redhat.com> (raw)
In-Reply-To: <1366306418-3661-1-git-send-email-nikolay@redhat.com>

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>
---
 drivers/net/bonding/bond_main.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 2e7fce0..c56e132 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1909,7 +1909,17 @@ err_detach:
 	bond_del_vlans_from_slave(bond, slave_dev);
 	write_lock_bh(&bond->lock);
 	bond_detach_slave(bond, new_slave);
+	if (bond->primary_slave == new_slave)
+		bond->primary_slave = NULL;
 	write_unlock_bh(&bond->lock);
+	if (bond->curr_active_slave == new_slave) {
+		read_lock(&bond->lock);
+		write_lock_bh(&bond->curr_slave_lock);
+		bond_change_active_slave(bond, NULL);
+		bond_select_active_slave(bond);
+		write_unlock_bh(&bond->curr_slave_lock);
+		read_unlock(&bond->lock);
+	}
 
 err_close:
 	slave_dev->priv_flags &= ~IFF_BONDING;
-- 
1.8.1.4

  parent reply	other threads:[~2013-04-18 17:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-18 17:33 [PATCHv2 0/5] bonding: enslave and locking bug fixes Nikolay Aleksandrov
2013-04-18 17:33 ` [PATCHv2 1/5] bonding: mc addresses don't get deleted on enslave failure Nikolay Aleksandrov
2013-04-18 17:33 ` [PATCHv2 2/5] bonding: vlans " Nikolay Aleksandrov
2013-04-18 17:33 ` Nikolay Aleksandrov [this message]
2013-04-18 17:39   ` [PATCHv3 3/5] bonding: primary_slave & curr_active_slave are not cleaned " Nikolay Aleksandrov
2013-04-18 17:33 ` [PATCHv2 4/5] bonding: disable netpoll " Nikolay Aleksandrov
2013-04-18 17:33 ` [PATCHv2 5/5] bonding: in bond_mc_swap() bond's mc addr list is walked without lock Nikolay Aleksandrov
2013-04-18 18:58 ` [PATCHv2 0/5] bonding: enslave and locking bug fixes Jay Vosburgh
2013-04-19 21:50   ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1366306418-3661-4-git-send-email-nikolay@redhat.com \
    --to=nikolay@redhat.com \
    --cc=andy@greyhouse.net \
    --cc=davem@davemloft.net \
    --cc=fubar@us.ibm.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).