[PATCH master 1/2] of: partition: skip NVMEM partition setup partition parsing fails
Ahmad Fatoum
a.fatoum at pengutronix.de
Tue Mar 14 01:58:04 PDT 2023
nvmem_partition_register should not be called with a NULL pointer
argument, yet this is what happened when a partition with a nvmem-cells
compatible conflicts with a partition parsed from an on-disk partition
table. Fix this.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
drivers/of/partition.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/of/partition.c b/drivers/of/partition.c
index ed1114193062..40c47f554ad2 100644
--- a/drivers/of/partition.c
+++ b/drivers/of/partition.c
@@ -70,10 +70,10 @@ struct cdev *of_parse_partition(struct cdev *cdev, struct device_node *node)
if (IS_ERR(new)) {
pr_err("Adding partition %s failed: %pe\n", filename, new);
new = NULL;
+ goto out;
}
- if (new)
- new->device_node = node;
+ new->device_node = node;
if (IS_ENABLED(CONFIG_NVMEM) && of_device_is_compatible(node, "nvmem-cells")) {
struct nvmem_device *nvmem = nvmem_partition_register(new);
@@ -81,6 +81,7 @@ struct cdev *of_parse_partition(struct cdev *cdev, struct device_node *node)
dev_warn(cdev->dev, "nvmem registeration failed: %pe\n", nvmem);
}
+out:
free(filename);
return new;
--
2.30.2
More information about the barebox
mailing list