[PATCH 1/2] bootm: always put a copy into data->of_root_node
Sascha Hauer
s.hauer at pengutronix.de
Thu Sep 21 04:04:56 PDT 2023
Never put of_get_root_node() directly into data->of_root_node, but
always a copy. With this we can unconditionally free data->of_root_node
in the cleanup path.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
common/bootm.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/common/bootm.c b/common/bootm.c
index 9ec4b127f8..27ada61f4e 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -404,10 +404,13 @@ void *bootm_get_devicetree(struct image_data *data)
}
} else {
- data->of_root_node = of_get_root_node();
- if (!data->of_root_node)
+ struct device_node *root = of_get_root_node();
+
+ if (!root)
return NULL;
+ data->of_root_node = of_dup(root);
+
if (bootm_verbose(data) > 1 && data->of_root_node)
printf("using internal devicetree\n");
}
@@ -838,7 +841,7 @@ int bootm_boot(struct bootm_data *bootm_data)
elf_close(data->elf);
if (IS_ENABLED(CONFIG_FITIMAGE) && data->os_fit)
fit_close(data->os_fit);
- if (data->of_root_node && data->of_root_node != of_get_root_node())
+ if (data->of_root_node)
of_delete_node(data->of_root_node);
globalvar_remove("linux.bootargs.bootm.earlycon");
--
2.39.2
More information about the barebox
mailing list