summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Cordahi <christophercordahi@nanometrics.ca>2012-12-17 01:59:30 +0100
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2013-02-04 08:26:28 +0100
commitebf4f0707df410a7666ec409ee68dc068db56e97 (patch)
tree88ae2ac1af8fab58c2764f49fba1a2dd4ab5e4d5
parentmtd: cmdlinepart: fix skipping zero sized partition (diff)
downloadlinux-ebf4f0707df410a7666ec409ee68dc068db56e97.tar.xz
linux-ebf4f0707df410a7666ec409ee68dc068db56e97.zip
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>
-rw-r--r--drivers/mtd/cmdlinepart.c17
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,
if (part->parts[i].size == SIZE_REMAINING)
part->parts[i].size = master->size - offset;
+ if (offset + part->parts[i].size > master->size) {
+ printk(KERN_WARNING ERRP
+ "%s: partitioning exceeds flash size, truncating\n",
+ part->mtd_id);
+ part->parts[i].size = master->size - offset;
+ }
+ offset += part->parts[i].size;
+
if (part->parts[i].size == 0) {
printk(KERN_WARNING ERRP
"%s: skipping zero sized partition\n",
@@ -338,16 +346,7 @@ static int parse_cmdline_partitions(struct mtd_info *master,
memmove(&part->parts[i], &part->parts[i + 1],
sizeof(*part->parts) * (part->num_parts - i));
i--;
- continue;
}
-
- if (offset + part->parts[i].size > master->size) {
- printk(KERN_WARNING ERRP
- "%s: partitioning exceeds flash size, truncating\n",
- part->mtd_id);
- part->parts[i].size = master->size - offset;
- }
- offset += part->parts[i].size;
}
*pparts = kmemdup(part->parts, sizeof(*part->parts) * part->num_parts,