mirror of
https://github.com/adulau/aha.git
synced 2024-12-27 19:26:25 +00:00
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>
This commit is contained in:
parent
4c1e6b2ce1
commit
ebf2e93036
1 changed files with 3 additions and 3 deletions
|
@ -427,7 +427,7 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr)
|
||||||
* to-be-erased area begins. Verify that the starting
|
* to-be-erased area begins. Verify that the starting
|
||||||
* offset is aligned to this region's erase size:
|
* 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;
|
return -EINVAL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -440,8 +440,8 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr)
|
||||||
/*
|
/*
|
||||||
* check if the ending offset is aligned to this region's erase size
|
* check if the ending offset is aligned to this region's erase size
|
||||||
*/
|
*/
|
||||||
if ((instr->addr + instr->len) & (erase_regions[i].erasesize -
|
if (i < 0 || ((instr->addr + instr->len) &
|
||||||
1))
|
(erase_regions[i].erasesize - 1)))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue