diff options
author | Roel Kluin <roel.kluin@gmail.com> | 2009-09-18 15:51:50 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2009-09-19 14:23:26 -0400 |
commit | a57ca0466af5da83e379d636b8c01fd53b41e2c6 (patch) | |
tree | c5f5d96fd9729aafe24aff8e6974bd6eea78a250 /drivers/mtd | |
parent | ebf2e93036907fe2a7ddab942aa63d35f97f3b2b (diff) |
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 <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')
-rw-r--r-- | drivers/mtd/mtdpart.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 349fcbe5cc0f..a83cfa1ad122 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c | |||
@@ -453,7 +453,8 @@ static struct mtd_part *add_one_partition(struct mtd_info *master, | |||
453 | for (i = 0; i < max && regions[i].offset <= slave->offset; i++) | 453 | for (i = 0; i < max && regions[i].offset <= slave->offset; i++) |
454 | ; | 454 | ; |
455 | /* The loop searched for the region _behind_ the first one */ | 455 | /* The loop searched for the region _behind_ the first one */ |
456 | i--; | 456 | if (i > 0) |
457 | i--; | ||
457 | 458 | ||
458 | /* Pick biggest erasesize */ | 459 | /* Pick biggest erasesize */ |
459 | for (; i < max && regions[i].offset < end; i++) { | 460 | for (; i < max && regions[i].offset < end; i++) { |