Skip to contentSkip to conversation

bnx2fc: protect kref_put by tgt_lock

PATCH New Arne Jansen 1 participant 1 message Dec 10, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bnx2fc: protect kref_put by tgt_lock

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.

---
 drivers/scsi/bnx2fc/bnx2fc_io.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 4c8122a82322..d0d465271e5c 100644

drivers/scsi/bnx2fc/bnx2fc_io.c +0 -0
@@ -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