diff options
author | Huang Shijie <b32955@freescale.com> | 2012-11-01 14:23:25 +0800 |
---|---|---|
committer | Jason Liu <r64343@freescale.com> | 2012-11-01 17:26:24 +0800 |
commit | a682070814006fc4ab71b90429d22e8bff76c873 (patch) | |
tree | c0649d63d29dbabe950ae6619fc109373faff5c9 | |
parent | cef937a37d83243181f84fa61c46cc0c7dbc96ab (diff) |
ENGR00232005 mtd: fix the overflow of big mtd partitions
When the kernel parses the following cmdline
#mtdparts=gpmi-nand:16m(boot),16m(kernel),1g(home),4g(test),-(usr)
for a big nand chip Micron MT29F64G08AFAAAWP(8GB), we got the following wrong
result:
.............................................
"mtd: partition size too small (0)"
.............................................
We can not get any partition.
The "4g(test)" partition triggers a overflow of the "size". The memparse()
returns 4g to the "size", but the size is "unsigned long" type, so a overflow
occurs, the "size" becomes zero in the end.
This patch changes the "size"/"offset" to "unsigned long long" type,
and replaces the UINT_MAX with ULLONG_MAX for macros SIZE_REMAINING and
OFFSET_CONTINUOUS.
Signed-off-by: Huang Shijie <b32955@freescale.com>
-rw-r--r-- | drivers/mtd/cmdlinepart.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c index fe33da403ab9..27d9dcc578a8 100644 --- a/drivers/mtd/cmdlinepart.c +++ b/drivers/mtd/cmdlinepart.c @@ -56,8 +56,8 @@ /* special size referring to all the remaining space in a partition */ -#define SIZE_REMAINING UINT_MAX -#define OFFSET_CONTINUOUS UINT_MAX +#define SIZE_REMAINING ULLONG_MAX +#define OFFSET_CONTINUOUS ULLONG_MAX struct cmdline_mtd_partition { struct cmdline_mtd_partition *next; @@ -89,8 +89,8 @@ static struct mtd_partition * newpart(char *s, int extra_mem_size) { struct mtd_partition *parts; - unsigned long size; - unsigned long offset = OFFSET_CONTINUOUS; + unsigned long long size; + unsigned long long offset = OFFSET_CONTINUOUS; char *name; int name_len; unsigned char *extra_mem; @@ -108,7 +108,7 @@ static struct mtd_partition * newpart(char *s, size = memparse(s, &s); if (size < PAGE_SIZE) { - printk(KERN_ERR ERRP "partition size too small (%lx)\n", size); + printk(KERN_ERR ERRP "partition size too small (%llx)\n", size); return NULL; } } @@ -319,7 +319,7 @@ static int parse_cmdline_partitions(struct mtd_info *master, struct mtd_partition **pparts, struct mtd_part_parser_data *data) { - unsigned long offset; + unsigned long long offset; int i; struct cmdline_mtd_partition *part; const char *mtd_id = master->name; |