Skip to content

Commit eafa655

Browse files
Arun Easigregkh
authored andcommitted
scsi: qla2xxx: Fix crash in NVMe abort path
commit e6e22e6 upstream. System crash was seen when I/O was run against an NVMe target and aborts were occurring. Crash stack is: -- relevant crash stack -- BUG: kernel NULL pointer dereference, address: 0000000000000010 : #6 [ffffae1f8666bdd0] page_fault at ffffffffa740122e [exception RIP: qla_nvme_abort_work+339] RIP: ffffffffc0f592e3 RSP: ffffae1f8666be80 RFLAGS: 00010297 RAX: 0000000000000000 RBX: ffff9b581fc8af80 RCX: ffffffffc0f83bd0 RDX: 0000000000000001 RSI: ffff9b5839c6c7c8 RDI: 0000000008000000 RBP: ffff9b6832f85000 R8: ffffffffc0f68160 R9: ffffffffc0f70652 R10: ffffae1f862ffdc8 R11: 0000000000000300 R12: 000000000000010d R13: 0000000000000000 R14: ffff9b5839cea000 R15: 0ffff9b583fab170 ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 #7 [ffffae1f8666be98] process_one_work at ffffffffa6aba184 #8 [ffffae1f8666bed8] worker_thread at ffffffffa6aba39d #9 [ffffae1f8666bf10] kthread at ffffffffa6ac06ed The crash was due to a stale SRB structure access after it was aborted. Fix the issue by removing stale access. Link: https://lore.kernel.org/r/[email protected] Fixes: 2cabf10 ("scsi: qla2xxx: Fix hang on NVMe command timeouts") Cc: [email protected] Reviewed-by: Himanshu Madhani <[email protected]> Signed-off-by: Arun Easi <[email protected]> Signed-off-by: Nilesh Javali <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 0bb97f2 commit eafa655

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

drivers/scsi/qla2xxx/qla_nvme.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ static void qla_nvme_abort_work(struct work_struct *work)
228228
fc_port_t *fcport = sp->fcport;
229229
struct qla_hw_data *ha = fcport->vha->hw;
230230
int rval, abts_done_called = 1;
231+
bool io_wait_for_abort_done;
232+
uint32_t handle;
231233

232234
ql_dbg(ql_dbg_io, fcport->vha, 0xffff,
233235
"%s called for sp=%p, hndl=%x on fcport=%p desc=%p deleted=%d\n",
@@ -244,12 +246,20 @@ static void qla_nvme_abort_work(struct work_struct *work)
244246
goto out;
245247
}
246248

249+
/*
250+
* sp may not be valid after abort_command if return code is either
251+
* SUCCESS or ERR_FROM_FW codes, so cache the value here.
252+
*/
253+
io_wait_for_abort_done = ql2xabts_wait_nvme &&
254+
QLA_ABTS_WAIT_ENABLED(sp);
255+
handle = sp->handle;
256+
247257
rval = ha->isp_ops->abort_command(sp);
248258

249259
ql_dbg(ql_dbg_io, fcport->vha, 0x212b,
250260
"%s: %s command for sp=%p, handle=%x on fcport=%p rval=%x\n",
251261
__func__, (rval != QLA_SUCCESS) ? "Failed to abort" : "Aborted",
252-
sp, sp->handle, fcport, rval);
262+
sp, handle, fcport, rval);
253263

254264
/*
255265
* If async tmf is enabled, the abort callback is called only on
@@ -264,7 +274,7 @@ static void qla_nvme_abort_work(struct work_struct *work)
264274
* are waited until ABTS complete. This kref is decreased
265275
* at qla24xx_abort_sp_done function.
266276
*/
267-
if (abts_done_called && ql2xabts_wait_nvme && QLA_ABTS_WAIT_ENABLED(sp))
277+
if (abts_done_called && io_wait_for_abort_done)
268278
return;
269279
out:
270280
/* kref_get was done before work was schedule. */

0 commit comments

Comments
 (0)