aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/devices
diff options
context:
space:
mode:
authorRoel Kluin <roel.kluin@gmail.com>2009-09-18 15:51:49 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2009-09-19 14:18:15 -0400
commit4c1e6b2ce13b154a4a69cee220c98976f4b784df (patch)
tree02109e88a695ab4dde00418a143cd7379911cc63 /drivers/mtd/devices
parentf12a9473283e68ae708e9ada37cb352ea2652397 (diff)
mtd: lart: Prevent a read from mtd->eraseregions[-1]
Signed-off-by: Roel Kluin <roel.kluin@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/devices')
-rw-r--r--drivers/mtd/devices/lart.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/mtd/devices/lart.c b/drivers/mtd/devices/lart.c
index 578de1c67bfe..f4359fe7150f 100644
--- a/drivers/mtd/devices/lart.c
+++ b/drivers/mtd/devices/lart.c
@@ -393,7 +393,8 @@ static int flash_erase (struct mtd_info *mtd,struct erase_info *instr)
393 * erase range is aligned with the erase size which is in 393 * erase range is aligned with the erase size which is in
394 * effect here. 394 * effect here.
395 */ 395 */
396 if (instr->addr & (mtd->eraseregions[i].erasesize - 1)) return (-EINVAL); 396 if (i < 0 || (instr->addr & (mtd->eraseregions[i].erasesize - 1)))
397 return -EINVAL;
397 398
398 /* Remember the erase region we start on */ 399 /* Remember the erase region we start on */
399 first = i; 400 first = i;
@@ -409,7 +410,8 @@ static int flash_erase (struct mtd_info *mtd,struct erase_info *instr)
409 i--; 410 i--;
410 411
411 /* is the end aligned on a block boundary? */ 412 /* is the end aligned on a block boundary? */
412 if ((instr->addr + instr->len) & (mtd->eraseregions[i].erasesize - 1)) return (-EINVAL); 413 if (i < 0 || ((instr->addr + instr->len) & (mtd->eraseregions[i].erasesize - 1)))
414 return -EINVAL;
413 415
414 addr = instr->addr; 416 addr = instr->addr;
415 len = instr->len; 417 len = instr->len;