diff options
author | Roel Kluin <roel.kluin@gmail.com> | 2009-09-18 15:51:49 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2009-09-19 14:18:46 -0400 |
commit | ebf2e93036907fe2a7ddab942aa63d35f97f3b2b (patch) | |
tree | 96661a766ddfa291782bded4c966c82445ca42eb /drivers/mtd/mtdconcat.c | |
parent | 4c1e6b2ce13b154a4a69cee220c98976f4b784df (diff) |
mtd: mtdconcat: prevent a read from eraseregions[-1]
If the erase region was found in the first iteration we read from
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/mtdconcat.c')
-rw-r--r-- | drivers/mtd/mtdconcat.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index 792b547786b8..db6de74082ad 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c | |||
@@ -427,7 +427,7 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
427 | * to-be-erased area begins. Verify that the starting | 427 | * to-be-erased area begins. Verify that the starting |
428 | * offset is aligned to this region's erase size: | 428 | * offset is aligned to this region's erase size: |
429 | */ | 429 | */ |
430 | if (instr->addr & (erase_regions[i].erasesize - 1)) | 430 | if (i < 0 || instr->addr & (erase_regions[i].erasesize - 1)) |
431 | return -EINVAL; | 431 | return -EINVAL; |
432 | 432 | ||
433 | /* | 433 | /* |
@@ -440,8 +440,8 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
440 | /* | 440 | /* |
441 | * check if the ending offset is aligned to this region's erase size | 441 | * check if the ending offset is aligned to this region's erase size |
442 | */ | 442 | */ |
443 | if ((instr->addr + instr->len) & (erase_regions[i].erasesize - | 443 | if (i < 0 || ((instr->addr + instr->len) & |
444 | 1)) | 444 | (erase_regions[i].erasesize - 1))) |
445 | return -EINVAL; | 445 | return -EINVAL; |
446 | } | 446 | } |
447 | 447 | ||