mtd: prevent a read from eraseregions[-1]
PATCH 10/13 mtd: prevent a read from eraseregions[-1]
From: Roel Kluin <[email protected]>
If the erase region was found in the first iteration we read from eraseregions[-1]
Signed-off-by Roel Kluin <[email protected]>
Cc David Woodhouse <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
drivers/mtd/mtdconcat.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/mtdconcat.c renamed from drivers/mtd/mtdconcat.c~mtd-prevent-a-read-from-eraseregions +3 -3
@@ -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 ; }
_