mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] bnx2fc: protect kref_put by tgt_lock
@ 2019-12-10 12:46 Arne Jansen
  0 siblings, 0 replies; only message in thread
From: Arne Jansen @ 2019-12-10 12:46 UTC (permalink / raw)
  To: linux-scsi, linux-kernel; +Cc: jejb, martin.petersen

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-12-10 12:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-10 12:46 [PATCH] bnx2fc: protect kref_put by tgt_lock Arne Jansen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®