Skip to content

Commit

Permalink
IB/srp: Fix a sporadic crash triggered by cable pulling
Browse files Browse the repository at this point in the history
commit 024ca90 upstream.

Avoid that the loops that iterate over the request ring can encounter
a pointer to a SCSI command in req->scmnd that is no longer associated
with that request. If the function srp_unmap_data() is invoked twice
for a SCSI command that is not in flight then that would cause
ib_fmr_pool_unmap() to be invoked with an invalid pointer as argument,
resulting in a kernel oops.

Reported-by: Sagi Grimberg <[email protected]>
Reference: http://thread.gmane.org/gmane.linux.drivers.rdma/19068/focus=19069
Signed-off-by: Bart Van Assche <[email protected]>
Reviewed-by: Sagi Grimberg <[email protected]>
Signed-off-by: Roland Dreier <[email protected]>
Signed-off-by: Jiri Slaby <[email protected]>
  • Loading branch information
bvanassche authored and Jiri Slaby committed Jul 17, 2014
1 parent aef0a96 commit 237de20
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/infiniband/ulp/srp/ib_srp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,12 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd)
err_iu:
srp_put_tx_iu(target, iu, SRP_IU_CMD);

/*
* Avoid that the loops that iterate over the request ring can
* encounter a dangling SCSI command pointer.
*/
req->scmnd = NULL;

spin_lock_irqsave(&target->lock, flags);
list_add(&req->list, &target->free_reqs);

Expand Down

0 comments on commit 237de20

Please sign in to comment.