mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master 1/4] of: only replace a device tree that is actually tentative
@ 2026-08-24 11:59 Ahmad Fatoum
  2026-08-24 11:59 ` [PATCH master 2/4] tlsf: unpoison whole block in malloc_usable_size() Ahmad Fatoum
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2026-08-24 11:59 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

barebox_register_of() is called a second time when the EFI payload
registers a device tree read from the EFI system partition on top of the
tentative empty device tree registered earlier at core_initcall.

The check that is meant to allow this looks at the children of the newly
passed device tree instead of those of the already registered one, so it
rejects exactly the case it was added for: registering a populated
device tree over the empty placeholder returns -EBUSY, while an empty
device tree may silently replace a fully populated one.

Look at the registered root node instead.

Fixes: 10922345fbcc ("efi: payload: register dummy device tree")
Assisted-by: Claude:opus-5
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/of/base.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 62d452907a57..2a2edc167cc6 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2151,7 +2151,11 @@ of_populate_initcall(barebox_of_populate);
 int barebox_register_of(struct device_node *root)
 {
 	if (root_node) {
-		if (!list_empty(&root->children))
+		/*
+		 * Only a tentative device tree, i.e. one without any nodes,
+		 * may be replaced by a real one.
+		 */
+		if (!list_empty(&root_node->children))
 			return -EBUSY;
 		/* Not necessarily safe to free, so leak it.. */
 		root_node = NULL;
-- 
2.47.3




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

end of thread, other threads:[~2026-08-24 13:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-24 11:59 [PATCH master 1/4] of: only replace a device tree that is actually tentative Ahmad Fatoum
2026-08-24 11:59 ` [PATCH master 2/4] tlsf: unpoison whole block in malloc_usable_size() Ahmad Fatoum
2026-08-24 11:59 ` [PATCH master 3/4] partitions: dos: bound extended partition chain Ahmad Fatoum
2026-08-24 11:59 ` [PATCH master 4/4] of: fdt: bound node nesting depth in __of_unflatten_dtb Ahmad Fatoum
2026-08-24 12:58 ` [PATCH master 1/4] of: only replace a device tree that is actually tentative Sascha Hauer

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