mtd: cmdlinepart: skip partitions truncated to zero
authorChristopher Cordahi <christophercordahi@nanometrics.ca>
Mon, 17 Dec 2012 00:59:30 +0000 (19:59 -0500)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Mon, 4 Feb 2013 07:26:28 +0000 (09:26 +0200)
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>
drivers/mtd/cmdlinepart.c

index c1efb4c1d3d2352268ecd7716b2ca1e4e90d90c5..525c5795d4f55c27cc7e11c9428f49d8b857f849 100644 (file)
@@ -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,