Skip to content

Commit ee92efe

Browse files
bvanasschejgunthorpe
authored andcommitted
IB/srp: Avoid that sg_reset -d ${srp_device} triggers an infinite loop
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]>
1 parent 5fe23f2 commit ee92efe

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
@@ -2951,7 +2951,7 @@ static int srp_reset_device(struct scsi_cmnd *scmnd)
29512951
{
29522952
struct srp_target_port *target = host_to_target(scmnd->device->host);
29532953
struct srp_rdma_ch *ch;
2954-
int i;
2954+
int i, j;
29552955
u8 status;
29562956

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

29662966
for (i = 0; i < target->ch_count; i++) {
29672967
ch = &target->ch[i];
2968-
for (i = 0; i < target->req_ring_size; ++i) {
2969-
struct srp_request *req = &ch->req_ring[i];
2968+
for (j = 0; j < target->req_ring_size; ++j) {
2969+
struct srp_request *req = &ch->req_ring[j];
29702970

29712971
srp_finish_req(ch, req, scmnd->device, DID_RESET << 16);
29722972
}

0 commit comments

Comments
 (0)