diff options
author | Bart Van Assche <bvanassche@acm.org> | 2014-05-20 09:03:49 -0400 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2014-05-20 12:20:51 -0400 |
commit | 024ca90151f5e4296d30f72c13ff9a075e23c9ec (patch) | |
tree | fe418c63a06d19c3739c58ff988ccf6b95d0d100 | |
parent | d6d211db37e75de2ddc3a4f979038c40df7cc79c (diff) |
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 <sagig@mellanox.com>
Reference: http://thread.gmane.org/gmane.linux.drivers.rdma/19068/focus=19069
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Roland Dreier <roland@purestorage.com>
-rw-r--r-- | drivers/infiniband/ulp/srp/ib_srp.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 66a908bf3fb9..5b2bed8fc493 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c | |||
@@ -1594,6 +1594,12 @@ err_unmap: | |||
1594 | err_iu: | 1594 | err_iu: |
1595 | srp_put_tx_iu(target, iu, SRP_IU_CMD); | 1595 | srp_put_tx_iu(target, iu, SRP_IU_CMD); |
1596 | 1596 | ||
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 | |||
1597 | spin_lock_irqsave(&target->lock, flags); | 1603 | spin_lock_irqsave(&target->lock, flags); |
1598 | list_add(&req->list, &target->free_reqs); | 1604 | list_add(&req->list, &target->free_reqs); |
1599 | 1605 | ||