]> Pileus Git - ~andy/linux/blobdiff - drivers/mtd/mtdcore.c
ASoC: uda1380: Return proper error in uda1380_modinit failure path
[~andy/linux] / drivers / mtd / mtdcore.c
index 887aed02aa2e5822f195868900ed0883b163cd91..b01993ea260ef95b064a04763989bc324f61a342 100644 (file)
@@ -449,7 +449,7 @@ out_error:
  *   is used, see 'parse_mtd_partitions()' for more information). If none are
  *   found this functions tries to fallback to information specified in
  *   @parts/@nr_parts.
- * * If any parititioning info was found, this function registers the found
+ * * If any partitioning info was found, this function registers the found
  *   partitions.
  * * If no partitions were found this function just registers the MTD device
  *   @mtd and exits.
@@ -465,12 +465,13 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char **types,
        struct mtd_partition *real_parts;
 
        err = parse_mtd_partitions(mtd, types, &real_parts, parser_data);
-       if (err <= 0 && nr_parts) {
+       if (err <= 0 && nr_parts && parts) {
                real_parts = kmemdup(parts, sizeof(*parts) * nr_parts,
                                     GFP_KERNEL);
-               err = nr_parts;
-               if (!parts)
+               if (!real_parts)
                        err = -ENOMEM;
+               else
+                       err = nr_parts;
        }
 
        if (err > 0) {