diff options
author | Christopher Cordahi <christophercordahi@nanometrics.ca> | 2012-12-16 19:59:30 -0500 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2013-02-04 02:26:28 -0500 |
commit | ebf4f0707df410a7666ec409ee68dc068db56e97 (patch) | |
tree | 88ae2ac1af8fab58c2764f49fba1a2dd4ab5e4d5 /drivers/mtd | |
parent | e25e0a4de1237972a86e5831c8659c4068ff23f7 (diff) |
mtd: cmdlinepart: skip partitions truncated to zero
Perform flash size truncation before skipping zero sized partition
so that if the result is a zero sized, it will be skipped like the
others.
Signed-off-by: Christopher Cordahi <christophercordahi@nanometrics.ca>
Acked-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/cmdlinepart.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c index c1efb4c1d3d2..525c5795d4f5 100644 --- a/drivers/mtd/cmdlinepart.c +++ b/drivers/mtd/cmdlinepart.c | |||
@@ -330,6 +330,14 @@ static int parse_cmdline_partitions(struct mtd_info *master, | |||
330 | if (part->parts[i].size == SIZE_REMAINING) | 330 | if (part->parts[i].size == SIZE_REMAINING) |
331 | part->parts[i].size = master->size - offset; | 331 | part->parts[i].size = master->size - offset; |
332 | 332 | ||
333 | if (offset + part->parts[i].size > master->size) { | ||
334 | printk(KERN_WARNING ERRP | ||
335 | "%s: partitioning exceeds flash size, truncating\n", | ||
336 | part->mtd_id); | ||
337 | part->parts[i].size = master->size - offset; | ||
338 | } | ||
339 | offset += part->parts[i].size; | ||
340 | |||
333 | if (part->parts[i].size == 0) { | 341 | if (part->parts[i].size == 0) { |
334 | printk(KERN_WARNING ERRP | 342 | printk(KERN_WARNING ERRP |
335 | "%s: skipping zero sized partition\n", | 343 | "%s: skipping zero sized partition\n", |
@@ -338,16 +346,7 @@ static int parse_cmdline_partitions(struct mtd_info *master, | |||
338 | memmove(&part->parts[i], &part->parts[i + 1], | 346 | memmove(&part->parts[i], &part->parts[i + 1], |
339 | sizeof(*part->parts) * (part->num_parts - i)); | 347 | sizeof(*part->parts) * (part->num_parts - i)); |
340 | i--; | 348 | i--; |
341 | continue; | ||
342 | } | 349 | } |
343 | |||
344 | if (offset + part->parts[i].size > master->size) { | ||
345 | printk(KERN_WARNING ERRP | ||
346 | "%s: partitioning exceeds flash size, truncating\n", | ||
347 | part->mtd_id); | ||
348 | part->parts[i].size = master->size - offset; | ||
349 | } | ||
350 | offset += part->parts[i].size; | ||
351 | } | 350 | } |
352 | 351 | ||
353 | *pparts = kmemdup(part->parts, sizeof(*part->parts) * part->num_parts, | 352 | *pparts = kmemdup(part->parts, sizeof(*part->parts) * part->num_parts, |