From 5eaa78d037bd69702cdd4cb70c30988cb77f9d43 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Sun, 2 Sep 2012 13:54:14 +0300 Subject: [PATCH] --- yaml --- r: 332735 b: refs/heads/master c: 9e0606fc4ea27fb275f6987751224c60ee055ef1 h: refs/heads/master i: 332733: 381b438e267c15cdc0aafb49db572af13ee32c6f 332731: 861117001055fe4d90a53af1acb05fbfbd91a5a2 332727: ba305be9e7813301a4ce479f05d964651fd769c3 332719: 4f0b9176a20f85029236c24f946a778c05e4689c 332703: aa05bff9964ba2a985e5d5278f6ad6fe9cbbe5ad 332671: 98c4c07717262b28ece7d21456f9f86fef15903e v: v3 --- [refs] | 2 +- trunk/drivers/mtd/cmdlinepart.c | 34 +++++++++++++++++---------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/[refs] b/[refs] index 4f0ce6993213..e6cd10ee2325 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 3cf7f1314ed88598b640318f60d8d5fb40509f23 +refs/heads/master: 9e0606fc4ea27fb275f6987751224c60ee055ef1 diff --git a/trunk/drivers/mtd/cmdlinepart.c b/trunk/drivers/mtd/cmdlinepart.c index b4faca25cf31..58dd0d0d7383 100644 --- a/trunk/drivers/mtd/cmdlinepart.c +++ b/trunk/drivers/mtd/cmdlinepart.c @@ -39,11 +39,10 @@ #include #include - #include #include -#include #include +#include /* error message prefix */ #define ERRP "mtd: " @@ -110,7 +109,7 @@ static struct mtd_partition * newpart(char *s, if (size < PAGE_SIZE) { printk(KERN_ERR ERRP "partition size too small (%lx)\n", size); - return NULL; + return ERR_PTR(-EINVAL); } } @@ -138,7 +137,7 @@ static struct mtd_partition * newpart(char *s, if (!p) { printk(KERN_ERR ERRP "no closing %c found in partition name\n", delim); - return NULL; + return ERR_PTR(-EINVAL); } name_len = p - name; s = p + 1; @@ -172,13 +171,13 @@ static struct mtd_partition * newpart(char *s, if (size == SIZE_REMAINING) { printk(KERN_ERR ERRP "no partitions allowed after a fill-up partition\n"); - return NULL; + return ERR_PTR(-EINVAL); } /* more partitions follow, parse them */ parts = newpart(s + 1, &s, num_parts, this_part + 1, &extra_mem, extra_mem_size); - if (!parts) - return NULL; + if (IS_ERR(parts)) + return parts; } else { /* this is the last partition: allocate space for all */ @@ -189,7 +188,7 @@ static struct mtd_partition * newpart(char *s, extra_mem_size; parts = kzalloc(alloc_size, GFP_KERNEL); if (!parts) - return NULL; + return ERR_PTR(-ENOMEM); extra_mem = (unsigned char *)(parts + *num_parts); } /* enter this partition (offset will be calculated later if it is zero at this point) */ @@ -245,7 +244,7 @@ static int mtdpart_setup_real(char *s) if (!(p = strchr(s, ':'))) { printk(KERN_ERR ERRP "no mtd-id\n"); - return 0; + return -EINVAL; } mtd_id_len = p - mtd_id; @@ -262,7 +261,7 @@ static int mtdpart_setup_real(char *s) (unsigned char**)&this_mtd, /* out: extra mem */ mtd_id_len + 1 + sizeof(*this_mtd) + sizeof(void*)-1 /*alignment*/); - if(!parts) + if (IS_ERR(parts)) { /* * An error occurred. We're either: @@ -271,7 +270,7 @@ static int mtdpart_setup_real(char *s) * Either way, this mtd is hosed and we're * unlikely to succeed in parsing any more */ - return 0; + return PTR_ERR(parts); } /* align this_mtd */ @@ -299,11 +298,11 @@ static int mtdpart_setup_real(char *s) if (*s != ';') { printk(KERN_ERR ERRP "bad character after partition (%c)\n", *s); - return 0; + return -EINVAL; } s++; } - return 1; + return 0; } /* @@ -318,13 +317,16 @@ static int parse_cmdline_partitions(struct mtd_info *master, struct mtd_part_parser_data *data) { unsigned long offset; - int i; + int i, err; struct cmdline_mtd_partition *part; const char *mtd_id = master->name; /* parse command line */ - if (!cmdline_parsed) - mtdpart_setup_real(cmdline); + if (!cmdline_parsed) { + err = mtdpart_setup_real(cmdline); + if (err) + return err; + } for(part = partitions; part; part = part->next) {