From: Arne Jansen <sensille@gmx.net>
To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: jejb@linux.ibm.com, martin.petersen@oracle.com
Subject: [PATCH] bnx2fc: protect kref_put by tgt_lock
Date: Tue, 10 Dec 2019 13:46:47 +0100 [thread overview]
Message-ID: <fca82c66-89cd-58fa-22a3-da628f85d1ff@gmx.net> (raw)
We have seen several kernel warning about list corruptions involving
bnx2fc_cmd.link. Reviewing the locking of this element showed that
in one instance a kref_put on io_req->refcount has been called without
tgt_lock. As the io_req might still be enqueued on a list protected by
this lock, this patch adds it. This was the only call site without it.
Signed-off-by: Arne Jansen <sensille@gmx.net>
---
drivers/scsi/bnx2fc/bnx2fc_io.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c
b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 4c8122a82322..d0d465271e5c 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -1097,6 +1097,9 @@ static int bnx2fc_abts_cleanup(struct bnx2fc_cmd
*io_req)
*/
time_left = wait_for_completion_timeout(&io_req->cleanup_done,
BNX2FC_FW_TIMEOUT);
+
+ spin_lock_bh(&tgt->tgt_lock);
+
if (!time_left) {
BNX2FC_IO_DBG(io_req, "%s(): Wait for cleanup timed
out.\n",
__func__);
@@ -1107,8 +1110,6 @@ static int bnx2fc_abts_cleanup(struct bnx2fc_cmd
*io_req)
*/
kref_put(&io_req->refcount, bnx2fc_cmd_release);
}
-
- spin_lock_bh(&tgt->tgt_lock);
io_req->wait_for_cleanup_comp = 0;
return SUCCESS;
}
--
2.11.0
reply other threads:[~2019-12-10 12:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=fca82c66-89cd-58fa-22a3-da628f85d1ff@gmx.net \
--to=sensille@gmx.net \
--cc=jejb@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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).