]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.160/ib-srp-avoid-that-sg_reset-d-srp_device-triggers-an-infinite-loop.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.160 / ib-srp-avoid-that-sg_reset-d-srp_device-triggers-an-infinite-loop.patch
CommitLineData
857085cb
GKH
1From ee92efe41cf358f4b99e73509f2bfd4733609f26 Mon Sep 17 00:00:00 2001
2From: Bart Van Assche <bvanassche@acm.org>
3Date: Mon, 17 Sep 2018 18:10:05 -0700
4Subject: IB/srp: Avoid that sg_reset -d ${srp_device} triggers an infinite loop
5
6From: Bart Van Assche <bvanassche@acm.org>
7
8commit ee92efe41cf358f4b99e73509f2bfd4733609f26 upstream.
9
10Use different loop variables for the inner and outer loop. This avoids
11that an infinite loop occurs if there are more RDMA channels than
12target->req_ring_size.
13
14Fixes: d92c0da71a35 ("IB/srp: Add multichannel support")
15Cc: <stable@vger.kernel.org>
16Signed-off-by: Bart Van Assche <bvanassche@acm.org>
17Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
18Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
19
20---
21 drivers/infiniband/ulp/srp/ib_srp.c | 6 +++---
22 1 file changed, 3 insertions(+), 3 deletions(-)
23
24--- a/drivers/infiniband/ulp/srp/ib_srp.c
25+++ b/drivers/infiniband/ulp/srp/ib_srp.c
26@@ -2594,7 +2594,7 @@ static int srp_reset_device(struct scsi_
27 {
28 struct srp_target_port *target = host_to_target(scmnd->device->host);
29 struct srp_rdma_ch *ch;
30- int i;
31+ int i, j;
32 u8 status;
33
34 shost_printk(KERN_ERR, target->scsi_host, "SRP reset_device called\n");
35@@ -2608,8 +2608,8 @@ static int srp_reset_device(struct scsi_
36
37 for (i = 0; i < target->ch_count; i++) {
38 ch = &target->ch[i];
39- for (i = 0; i < target->req_ring_size; ++i) {
40- struct srp_request *req = &ch->req_ring[i];
41+ for (j = 0; j < target->req_ring_size; ++j) {
42+ struct srp_request *req = &ch->req_ring[j];
43
44 srp_finish_req(ch, req, scmnd->device, DID_RESET << 16);
45 }