mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] bootm: always put a copy into data->of_root_node
@ 2023-09-21 11:04 Sascha Hauer
  2023-09-21 11:04 ` [PATCH 2/2] bootm: fix printing kernel command line Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Sascha Hauer @ 2023-09-21 11:04 UTC (permalink / raw)
  To: Barebox List

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@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




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-09-21 11:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-21 11:04 [PATCH 1/2] bootm: always put a copy into data->of_root_node Sascha Hauer
2023-09-21 11:04 ` [PATCH 2/2] bootm: fix printing kernel command line Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox