netns xfrm: fix "ip xfrm state|policy count" misreport
[safe/jmp/linux-2.6] / drivers / mtd / cmdlinepart.c
index 68782ab..1479da6 100644 (file)
@@ -7,6 +7,7 @@
  *
  * mtdparts=<mtddef>[;<mtddef]
  * <mtddef>  := <mtd-id>:<partdef>[,<partdef>]
+ *              where <mtd-id> is the name from the "cat /proc/mtd" command
  * <partdef> := <size>[@offset][<name>][ro][lk]
  * <mtd-id>  := unique name used in mapping driver/device (mtd->name)
  * <size>    := standard linux memsize OR "-" to denote all remaining space
@@ -193,7 +194,7 @@ static struct mtd_partition * newpart(char *s,
        parts[this_part].name = extra_mem;
        extra_mem += name_len + 1;
 
-       dbg(("partition %d: name <%s>, offset %x, size %x, mask flags %x\n",
+       dbg(("partition %d: name <%s>, offset %llx, size %llx, mask flags %x\n",
             this_part,
             parts[this_part].name,
             parts[this_part].offset,
@@ -306,7 +307,7 @@ static int parse_cmdline_partitions(struct mtd_info *master,
        unsigned long offset;
        int i;
        struct cmdline_mtd_partition *part;
-       char *mtd_id = master->name;
+       const char *mtd_id = master->name;
 
        /* parse command line */
        if (!cmdline_parsed)
@@ -334,7 +335,11 @@ static int parse_cmdline_partitions(struct mtd_info *master,
                                }
                                offset += part->parts[i].size;
                        }
-                       *pparts = part->parts;
+                       *pparts = kmemdup(part->parts,
+                                       sizeof(*part->parts) * part->num_parts,
+                                       GFP_KERNEL);
+                       if (!*pparts)
+                               return -ENOMEM;
                        return part->num_parts;
                }
        }