Skip to content

Commit

Permalink
Staging: rts_pstor: off by one in for loop
Browse files Browse the repository at this point in the history
I already fixed the other similar for loop in this file.  I'm not sure
how I missed this one.  We use seg_no+1 inside the loop so we can't go
right up to the end of the loop.

Also if we don't break out of the loop then we end up past the end of
the array, but with this fix we end up on the last element.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Dan Carpenter authored and Greg Kroah-Hartman committed Apr 10, 2012
1 parent 678b7c1 commit 3fd654c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/staging/rts_pstor/ms.c
Original file line number Diff line number Diff line change
Expand Up @@ -3498,7 +3498,8 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32

log_blk++;

for (seg_no = 0; seg_no < sizeof(ms_start_idx)/2; seg_no++) {
for (seg_no = 0; seg_no < ARRAY_SIZE(ms_start_idx) - 1;
seg_no++) {
if (log_blk < ms_start_idx[seg_no+1])
break;
}
Expand Down

0 comments on commit 3fd654c

Please sign in to comment.