Skip to content

Commit

Permalink
mtd: mtdpart: prevent a read from regions[-1]
Browse files Browse the repository at this point in the history
If the erase region was found in the first iteration we read from
regions[-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>
  • Loading branch information
Roel Kluin authored and David Woodhouse committed Sep 19, 2009
1 parent ebf2e93 commit a57ca04
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/mtd/mtdpart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down

0 comments on commit a57ca04

Please sign in to comment.