netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ursula Braun <ubraun@linux.ibm.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-s390@vger.kernel.org,
	heiko.carstens@de.ibm.com, raspl@linux.ibm.com,
	kgraul@linux.ibm.com, ubraun@linux.ibm.com
Subject: [PATCH net-next 3/6] net/smc: do not delete lgr from list twice
Date: Mon, 17 Feb 2020 16:24:52 +0100	[thread overview]
Message-ID: <20200217152455.15341-4-ubraun@linux.ibm.com> (raw)
In-Reply-To: <20200217152455.15341-1-ubraun@linux.ibm.com>

From: Karsten Graul <kgraul@linux.ibm.com>

When 2 callers call smc_lgr_terminate() at the same time
for the same lgr, one gets the lgr_lock and deletes the lgr from the
list and releases the lock. Then the second caller gets the lock and
tries to delete it again.
In smc_lgr_terminate() add a check if the link group lgr is already
deleted from the link group list and prevent to try to delete it a
second time.
And add a check if the lgr is marked as freeing, which means that a
termination is already pending.

Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
---
 net/smc/smc_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
index 8f3c1fced334..9b92b52952dd 100644
--- a/net/smc/smc_core.c
+++ b/net/smc/smc_core.c
@@ -629,7 +629,7 @@ void smc_lgr_terminate(struct smc_link_group *lgr, bool soft)
 
 	smc_lgr_list_head(lgr, &lgr_lock);
 	spin_lock_bh(lgr_lock);
-	if (lgr->terminating) {
+	if (list_empty(&lgr->list) || lgr->terminating || lgr->freeing) {
 		spin_unlock_bh(lgr_lock);
 		return;	/* lgr already terminating */
 	}
-- 
2.17.1


  parent reply	other threads:[~2020-02-17 15:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-17 15:24 [PATCH net-next 0/6] net/smc: patches 2020-02-17 Ursula Braun
2020-02-17 15:24 ` [PATCH net-next 1/6] net/smc: improve smc_lgr_cleanup() Ursula Braun
2020-02-17 15:24 ` [PATCH net-next 2/6] net/smc: use termination worker under send_lock Ursula Braun
2020-02-17 15:24 ` Ursula Braun [this message]
2020-02-17 15:24 ` [PATCH net-next 4/6] net/smc: remove unused parameter of smc_lgr_terminate() Ursula Braun
2020-02-17 15:24 ` [PATCH net-next 5/6] net/smc: simplify normal link termination Ursula Braun
2020-02-17 15:24 ` [PATCH net-next 6/6] net/smc: reduce port_event scheduling Ursula Braun
2020-02-17 22:50 ` [PATCH net-next 0/6] net/smc: patches 2020-02-17 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=20200217152455.15341-4-ubraun@linux.ibm.com \
    --to=ubraun@linux.ibm.com \
    --cc=davem@davemloft.net \
    --cc=heiko.carstens@de.ibm.com \
    --cc=kgraul@linux.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=raspl@linux.ibm.com \
    /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).