mtd: mtdpart: prevent a read from regions[-1]

If the erase region was found in the first iteration we read from
regions[-1]

Signed-off-by: Roel Kluin <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: David Woodhouse <[email protected]>
This commit is contained in:
Roel Kluin 2009-09-18 12:51:50 -07:00 • committed by David Woodhouse
commit a57ca0466a

View file

@ -453,7 +453,8 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
for (i = 0; i < max && regions[i].offset <= slave->offset; i++)
;
/* The loop searched for the region _behind_ the first one */
i--;
if (i > 0)
i--;
/* Pick biggest erasesize */
for (; i < max && regions[i].offset < end; i++) {