Signed-off-by: Mathias Kresin <openwrt@kresin.me>
---
- drivers/mtd/parsers/ofpart_core.c | 49 ++++++++++++++++++++++++++++++-
- 1 file changed, 48 insertions(+), 1 deletion(-)
+ drivers/mtd/parsers/ofpart_core.c | 53 +++++++++++++++++++++++++++++++
+ 1 file changed, 53 insertions(+)
--- a/drivers/mtd/parsers/ofpart_core.c
+++ b/drivers/mtd/parsers/ofpart_core.c
/* Pull of_node from the master device node */
mtd_node = mtd_get_of_node(master);
-@@ -95,7 +129,9 @@ static int parse_fixed_partitions(struct
- return 0;
+@@ -98,6 +132,14 @@ static int parse_fixed_partitions(struct
+ if (!parts)
+ return -ENOMEM;
- parts = kcalloc(nr_parts, sizeof(*parts), GFP_KERNEL);
-- if (!parts)
+ part_nodes = kcalloc(nr_parts, sizeof(*part_nodes), GFP_KERNEL);
++ if (!part_nodes) {
++ if (dedicated)
++ of_node_put(ofpart_node);
++ kfree(parts);
++ return -ENOMEM;
++ }
+
-+ if (!parts || !part_nodes)
- return -ENOMEM;
-
i = 0;
-@@ -166,6 +202,11 @@ static int parse_fixed_partitions(struct
+ for_each_child_of_node(ofpart_node, pp) {
+ const __be32 *reg;
+@@ -166,6 +208,11 @@ static int parse_fixed_partitions(struct
if (of_property_read_bool(pp, "slc-mode"))
parts[i].add_flags |= MTD_SLC_ON_MLC_EMULATION;
i++;
}
-@@ -175,6 +216,11 @@ static int parse_fixed_partitions(struct
+@@ -175,6 +222,11 @@ static int parse_fixed_partitions(struct
if (quirks && quirks->post_parse)
quirks->post_parse(master, parts, nr_parts);
*pparts = parts;
return nr_parts;
-@@ -185,6 +231,7 @@ ofpart_fail:
+@@ -185,6 +237,7 @@ ofpart_fail:
ofpart_none:
of_node_put(pp);
kfree(parts);