Skip to content

Commit 024ca90

Browse files
bvanasscherolandd
authored andcommitted
IB/srp: Fix a sporadic crash triggered by cable pulling
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]> Cc: stable <[email protected]> Signed-off-by: Roland Dreier <[email protected]>
1 parent d6d211d commit 024ca90

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/infiniband/ulp/srp/ib_srp.c

+6
Original file line numberDiff line numberDiff line change
@@ -1594,6 +1594,12 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd)
15941594
err_iu:
15951595
srp_put_tx_iu(target, iu, SRP_IU_CMD);
15961596

1597+
/*
1598+
* Avoid that the loops that iterate over the request ring can
1599+
* encounter a dangling SCSI command pointer.
1600+
*/
1601+
req->scmnd = NULL;
1602+
15971603
spin_lock_irqsave(&target->lock, flags);
15981604
list_add(&req->list, &target->free_reqs);
15991605

0 commit comments

Comments
 (0)