Staging: rts_pstor: fix read past end of buffer
authorDan Carpenter <error27@gmail.com>
Wed, 9 Feb 2011 09:40:12 +0000 (12:40 +0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 9 Feb 2011 20:11:55 +0000 (12:11 -0800)
We read one space past the end of the buffer because we add 1.

Also I changed it to use ARRAY_SIZE() instead of manually calculating
the size.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/rts_pstor/ms.c

index dd599316859869a49b838f940d34783033daa4d6..a624f40fd914ca3c6ebd9fd1eccb6958d412e747 100644 (file)
@@ -3361,7 +3361,7 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32
        log_blk = (u16)(start_sector >> ms_card->block_shift);
        start_page = (u8)(start_sector & ms_card->page_off);
 
-       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;
        }