[patch 10/13] mtd: prevent a read from eraseregions[-1]
akpm at linux-foundation.org
akpm at linux-foundation.org
Fri Sep 18 15:51:49 EDT 2009
From: Roel Kluin <roel.kluin at gmail.com>
If the erase region was found in the first iteration we read from
eraseregions[-1]
Signed-off-by: Roel Kluin <roel.kluin at gmail.com>
Cc: David Woodhouse <dwmw2 at infradead.org>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
---
drivers/mtd/mtdconcat.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff -puN drivers/mtd/mtdconcat.c~mtd-prevent-a-read-from-eraseregions drivers/mtd/mtdconcat.c
--- a/drivers/mtd/mtdconcat.c~mtd-prevent-a-read-from-eraseregions
+++ a/drivers/mtd/mtdconcat.c
@@ -427,7 +427,7 @@ static int concat_erase(struct mtd_info
* to-be-erased area begins. Verify that the starting
* offset is aligned to this region's erase size:
*/
- if (instr->addr & (erase_regions[i].erasesize - 1))
+ if (i < 0 || instr->addr & (erase_regions[i].erasesize - 1))
return -EINVAL;
/*
@@ -440,8 +440,8 @@ static int concat_erase(struct mtd_info
/*
* check if the ending offset is aligned to this region's erase size
*/
- if ((instr->addr + instr->len) & (erase_regions[i].erasesize -
- 1))
+ if (i < 0 || ((instr->addr + instr->len) &
+ (erase_regions[i].erasesize - 1)))
return -EINVAL;
}
_
More information about the linux-mtd
mailing list