[PATCH] of: gracefully handle empty dummy DT

Ahmad Fatoum a.fatoum at pengutronix.de
Tue Apr 14 07:57:33 PDT 2026


We started registering an empty dummy DT on platforms with barebox as
EFI payload to allow a multi-platform build where some enabled SoCs
expect a DT to be available.

This fixes some problems, but causes others, because we have places in
the code that assume there is always a compatible property when there is
a device tree.

Adapt these places to treat lack of oftree and compatible the same.

Fixes: 10922345fbcc ("efi: payload: register dummy device tree")
Reported-by: Chali Anis <chalianis1 at gmail.com>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 common/blspec.c    | 4 ++--
 common/image-fit.c | 2 +-
 common/oftree.c    | 2 ++
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/common/blspec.c b/common/blspec.c
index c07e3a2d672d..c90bead4f355 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -336,14 +336,14 @@ static bool entry_is_of_compatible(struct blspec_entry *entry)
 	if (!strcmp(devicetree, "none"))
 		return true;
 
-	/* If we don't have a root node every entry is compatible */
+	/* If we don't have a root node with a compatible, every entry is compatible */
 	barebox_root = of_get_root_node();
 	if (!barebox_root)
 		return true;
 
 	ret = of_property_read_string(barebox_root, "compatible", &compat);
 	if (ret)
-		return false;
+		return true;
 
 	if (entry->rootpath)
 		abspath = entry->rootpath;
diff --git a/common/image-fit.c b/common/image-fit.c
index 7bc4665fcdbc..8e6f3d2b5d3c 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -891,7 +891,7 @@ static int fit_find_compatible_unit(struct fit_handle *handle,
 
 	ret = of_property_read_string(barebox_root, "compatible", &machine);
 	if (ret)
-		return -ENOENT;
+		goto default_unit;
 
 	for_each_child_of_node(conf_node, child) {
 		int score;
diff --git a/common/oftree.c b/common/oftree.c
index 2bf1a63e4915..7aaed70e4016 100644
--- a/common/oftree.c
+++ b/common/oftree.c
@@ -550,6 +550,8 @@ int of_prepend_machine_compatible(struct device_node *root, const char *compat)
 		return 0;
 
 	curcompat = of_get_property(root, "compatible", &cclen);
+	if (!curcompat)
+		return -ENOENT;
 
 	buf = xzalloc(cclen + clen);
 
-- 
2.47.3




More information about the barebox mailing list