diff options
author | Shmulik Ladkani <shmulik.ladkani@gmail.com> | 2012-09-05 01:30:20 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-09-29 10:44:25 -0400 |
commit | 7baf04261062826ea225ab23e07c541e279143fa (patch) | |
tree | 8cb93944ca5a5d073d7eb6868e7f67374e614fa7 /drivers/mtd/cmdlinepart.c | |
parent | 2fe87aef33b77d66fada83f5dc57b6798ad5df07 (diff) |
mtd: cmdlinepart: make the partitions rule more strict
Huang Shijie <shijie8@gmail.com> explains:
Assume we have a 1GiB(8Gib) NAND chip, and we set the partitions
in the command line like this:
#gpmi-nand:100m(boot),100m(kernel),1g(rootfs)
In this case, the partition truncating occurs. The current code will
get the following result:
----------------------------------
root@freescale ~$ cat /proc/mtd
dev: size erasesize name
mtd0: 06400000 00040000 "boot"
mtd1: 06400000 00040000 "kernel"
----------------------------------
It is obvious that we lost the truncated partition `rootfs` which should
be 824MiB in this case.
Also, forbid 0-sized partitions.
Signed-off-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/cmdlinepart.c')
-rw-r--r-- | drivers/mtd/cmdlinepart.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c index 17b0bd463839..aed1b8a63c9f 100644 --- a/drivers/mtd/cmdlinepart.c +++ b/drivers/mtd/cmdlinepart.c | |||
@@ -319,12 +319,22 @@ static int parse_cmdline_partitions(struct mtd_info *master, | |||
319 | if (part->parts[i].size == SIZE_REMAINING) | 319 | if (part->parts[i].size == SIZE_REMAINING) |
320 | part->parts[i].size = master->size - offset; | 320 | part->parts[i].size = master->size - offset; |
321 | 321 | ||
322 | if (part->parts[i].size == 0) { | ||
323 | printk(KERN_WARNING ERRP | ||
324 | "%s: skipping zero sized partition\n", | ||
325 | part->mtd_id); | ||
326 | part->num_parts--; | ||
327 | memmove(&part->parts[i], | ||
328 | &part->parts[i + 1], | ||
329 | sizeof(*part->parts) * (part->num_parts - i)); | ||
330 | continue; | ||
331 | } | ||
332 | |||
322 | if (offset + part->parts[i].size > master->size) { | 333 | if (offset + part->parts[i].size > master->size) { |
323 | printk(KERN_WARNING ERRP | 334 | printk(KERN_WARNING ERRP |
324 | "%s: partitioning exceeds flash size, truncating\n", | 335 | "%s: partitioning exceeds flash size, truncating\n", |
325 | part->mtd_id); | 336 | part->mtd_id); |
326 | part->parts[i].size = master->size - offset; | 337 | part->parts[i].size = master->size - offset; |
327 | part->num_parts = i; | ||
328 | } | 338 | } |
329 | offset += part->parts[i].size; | 339 | offset += part->parts[i].size; |
330 | } | 340 | } |