Skip to content

Commit fcbe49c

Browse files
bvanasschegregkh
authored andcommitted
IB/srp: Avoid that sg_reset -d ${srp_device} triggers an infinite loop
commit ee92efe upstream. Use different loop variables for the inner and outer loop. This avoids that an infinite loop occurs if there are more RDMA channels than target->req_ring_size. Fixes: d92c0da ("IB/srp: Add multichannel support") Cc: <[email protected]> Signed-off-by: Bart Van Assche <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3011b91 commit fcbe49c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/infiniband/ulp/srp/ib_srp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2669,7 +2669,7 @@ static int srp_reset_device(struct scsi_cmnd *scmnd)
26692669
{
26702670
struct srp_target_port *target = host_to_target(scmnd->device->host);
26712671
struct srp_rdma_ch *ch;
2672-
int i;
2672+
int i, j;
26732673
u8 status;
26742674

26752675
shost_printk(KERN_ERR, target->scsi_host, "SRP reset_device called\n");
@@ -2683,8 +2683,8 @@ static int srp_reset_device(struct scsi_cmnd *scmnd)
26832683

26842684
for (i = 0; i < target->ch_count; i++) {
26852685
ch = &target->ch[i];
2686-
for (i = 0; i < target->req_ring_size; ++i) {
2687-
struct srp_request *req = &ch->req_ring[i];
2686+
for (j = 0; j < target->req_ring_size; ++j) {
2687+
struct srp_request *req = &ch->req_ring[j];
26882688

26892689
srp_finish_req(ch, req, scmnd->device, DID_RESET << 16);
26902690
}

0 commit comments

Comments
 (0)