Skip to content

Commit 0b4ea5b

Browse files
mikechristiegregkh
authored andcommitted
scsi: qedi: Fix ABBA deadlock in qedi_process_tmf_resp() and qedi_process_cmd_cleanup_resp()
commit f10f582 upstream. This fixes a deadlock added with commit b40f389 ("scsi: qedi: Complete TMF works before disconnect") Bug description from Jia-Ju Bai: qedi_process_tmf_resp() spin_lock(&session->back_lock); --> Line 201 (Lock A) spin_lock(&qedi_conn->tmf_work_lock); --> Line 230 (Lock B) qedi_process_cmd_cleanup_resp() spin_lock_bh(&qedi_conn->tmf_work_lock); --> Line 752 (Lock B) spin_lock_bh(&conn->session->back_lock); --> Line 784 (Lock A) When qedi_process_tmf_resp() and qedi_process_cmd_cleanup_resp() are concurrently executed, the deadlock can occur. This patch fixes the deadlock by not holding the tmf_work_lock in qedi_process_cmd_cleanup_resp while holding the back_lock. The tmf_work_lock is only needed while we remove the tmf_work from the work_list. Link: https://lore.kernel.org/r/20220208185448.6206-1-michael.christie@oracle.com Fixes: b40f389 ("scsi: qedi: Complete TMF works before disconnect") Cc: Manish Rangankar <mrangankar@marvell.com> Cc: Nilesh Javali <njavali@marvell.com> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn> Reported-by: Jia-Ju Bai <baijiaju1990@gmail.com> Signed-off-by: Mike Christie <michael.christie@oracle.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 795feaf commit 0b4ea5b

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

drivers/scsi/qedi/qedi_fw.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -772,11 +772,10 @@ static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi,
772772
qedi_cmd->list_tmf_work = NULL;
773773
}
774774
}
775+
spin_unlock_bh(&qedi_conn->tmf_work_lock);
775776

776-
if (!found) {
777-
spin_unlock_bh(&qedi_conn->tmf_work_lock);
777+
if (!found)
778778
goto check_cleanup_reqs;
779-
}
780779

781780
QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_SCSI_TM,
782781
"TMF work, cqe->tid=0x%x, tmf flags=0x%x, cid=0x%x\n",
@@ -807,7 +806,6 @@ static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi,
807806
qedi_cmd->state = CLEANUP_RECV;
808807
unlock:
809808
spin_unlock_bh(&conn->session->back_lock);
810-
spin_unlock_bh(&qedi_conn->tmf_work_lock);
811809
wake_up_interruptible(&qedi_conn->wait_queue);
812810
return;
813811

0 commit comments

Comments
 (0)