Avoid that srp_finish_req() can encounter a pointer to a SCSI command
in req->scmnd that is no longer associated with that request. If the
function srp_finish_req() is invoked twice for a SCSI command that is
not in flight then that would cause srp_unmap_data() to try to invoke
ib_fmr_pool_unmap() 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]>
Cc: Roland Dreier <[email protected]>
Cc: David Dillow <[email protected]>
Cc: Sagi Grimberg <[email protected]>
Cc: Vu Pham <[email protected]>
Cc: Sebastian Parschauer <[email protected]>
Cc: stable <[email protected]> # 3.13+ ("IB/srp: Use SRP transport layer 
error recovery")
---
 drivers/infiniband/ulp/srp/ib_srp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/infiniband/ulp/srp/ib_srp.c 
b/drivers/infiniband/ulp/srp/ib_srp.c
index 66a908b..427336a 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1594,6 +1594,8 @@ err_unmap:
 err_iu:
        srp_put_tx_iu(target, iu, SRP_IU_CMD);
 
+       req->scmnd = NULL; /* for srp_finish_req() */
+
        spin_lock_irqsave(&target->lock, flags);
        list_add(&req->list, &target->free_reqs);
 
-- 
1.8.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to