Skip to content

Commit e193b79

Browse files
bvanasscherleon
authored andcommitted
RDMA/srp: Do not call scsi_done() from srp_abort()
After scmd_eh_abort_handler() has called the SCSI LLD eh_abort_handler callback, it performs one of the following actions: * Call scsi_queue_insert(). * Call scsi_finish_command(). * Call scsi_eh_scmd_add(). Hence, SCSI abort handlers must not call scsi_done(). Otherwise all the above actions would trigger a use-after-free. Hence remove the scsi_done() call from srp_abort(). Keep the srp_free_req() call before returning SUCCESS because we may not see the command again if SUCCESS is returned. Cc: Bob Pearson <[email protected]> Cc: Shinichiro Kawasaki <[email protected]> Fixes: d853667 ("IB/srp: Avoid having aborted requests hang") Signed-off-by: Bart Van Assche <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Leon Romanovsky <[email protected]>
1 parent 0bb80ec commit e193b79

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

drivers/infiniband/ulp/srp/ib_srp.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2784,7 +2784,6 @@ static int srp_abort(struct scsi_cmnd *scmnd)
27842784
u32 tag;
27852785
u16 ch_idx;
27862786
struct srp_rdma_ch *ch;
2787-
int ret;
27882787

27892788
shost_printk(KERN_ERR, target->scsi_host, "SRP abort called\n");
27902789

@@ -2798,19 +2797,14 @@ static int srp_abort(struct scsi_cmnd *scmnd)
27982797
shost_printk(KERN_ERR, target->scsi_host,
27992798
"Sending SRP abort for tag %#x\n", tag);
28002799
if (srp_send_tsk_mgmt(ch, tag, scmnd->device->lun,
2801-
SRP_TSK_ABORT_TASK, NULL) == 0)
2802-
ret = SUCCESS;
2803-
else if (target->rport->state == SRP_RPORT_LOST)
2804-
ret = FAST_IO_FAIL;
2805-
else
2806-
ret = FAILED;
2807-
if (ret == SUCCESS) {
2800+
SRP_TSK_ABORT_TASK, NULL) == 0) {
28082801
srp_free_req(ch, req, scmnd, 0);
2809-
scmnd->result = DID_ABORT << 16;
2810-
scsi_done(scmnd);
2802+
return SUCCESS;
28112803
}
2804+
if (target->rport->state == SRP_RPORT_LOST)
2805+
return FAST_IO_FAIL;
28122806

2813-
return ret;
2807+
return FAILED;
28142808
}
28152809

28162810
static int srp_reset_device(struct scsi_cmnd *scmnd)

0 commit comments

Comments
 (0)