]>
Commit | Line | Data |
---|---|---|
857085cb GKH |
1 | From ee92efe41cf358f4b99e73509f2bfd4733609f26 Mon Sep 17 00:00:00 2001 |
2 | From: Bart Van Assche <bvanassche@acm.org> | |
3 | Date: Mon, 17 Sep 2018 18:10:05 -0700 | |
4 | Subject: IB/srp: Avoid that sg_reset -d ${srp_device} triggers an infinite loop | |
5 | ||
6 | From: Bart Van Assche <bvanassche@acm.org> | |
7 | ||
8 | commit ee92efe41cf358f4b99e73509f2bfd4733609f26 upstream. | |
9 | ||
10 | Use different loop variables for the inner and outer loop. This avoids | |
11 | that an infinite loop occurs if there are more RDMA channels than | |
12 | target->req_ring_size. | |
13 | ||
14 | Fixes: d92c0da71a35 ("IB/srp: Add multichannel support") | |
15 | Cc: <stable@vger.kernel.org> | |
16 | Signed-off-by: Bart Van Assche <bvanassche@acm.org> | |
17 | Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> | |
18 | Signed-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 | } |