From: Dan Carpenter Date: Wed, 9 Feb 2011 09:40:12 +0000 (+0300) Subject: Staging: rts_pstor: fix read past end of buffer X-Git-Tag: MMI-PSA29.97-13-9~20521^2~616 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7e79f78b331632c1812ce9c07443550aa2b6c0fe;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git Staging: rts_pstor: fix read past end of buffer 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/rts_pstor/ms.c b/drivers/staging/rts_pstor/ms.c index dd5993168598..a624f40fd914 100644 --- a/drivers/staging/rts_pstor/ms.c +++ b/drivers/staging/rts_pstor/ms.c @@ -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; }