* [PATCH 1/2] of: overlay: of_overlay_fix_path: allow symbols without __overlay__
2026-10-14 15:09 [PATCH 0/2] of: overlay: of_overlay_fix_path: allow symbols without __overlay__ Stefan Kerkmann
@ 2026-10-14 15:09 ` Stefan Kerkmann
2026-10-14 15:09 ` [PATCH 2/2] of: overlay: fix_path/apply_symbols: add more debugging calls Stefan Kerkmann
2026-10-15 11:03 ` [PATCH 0/2] of: overlay: of_overlay_fix_path: allow symbols without __overlay__ Stefan Kerkmann
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Kerkmann @ 2026-10-14 15:09 UTC (permalink / raw)
To: Sascha Hauer, open list:BAREBOX; +Cc: Stefan Kerkmann
An overlay with a label entry in the `__symbols__` table without a
matching fragment that contains an `__overlay__` is not an error. This
matches the behavior of the dtc libfdt implementation[1].
This edge case was triggered by:
1. Enabling CONFIG_OF_OVERLAY_LIVE this adds a `__symbols__` table to
device trees compiled by barebox.
2. Passing the barebox devicetree via TF-A to OP-TEE that adds overlay
fragments to the barebox device tree.
3. Enabling CONFIG_OPTEE_APPLY_OVERLAY and applying the same DT again as
a DT overlay. The DT in this case was expanded by OP-TEE with overlay
fragments (and still contains the __symbol__ table with entries that
do not reference the OP-TEE fragments).
[1]: 5c715a4 ("fdtoverlay: Ignore symbols in overlays which don't apply to the target tree")
Fixes: 6553d2c2a5e3 ("of: overlay: avoid potential null pointer exception")
Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de>
---
drivers/of/overlay.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
index 4ce45513ea..410c6d3565 100644
--- a/drivers/of/overlay.c
+++ b/drivers/of/overlay.c
@@ -110,13 +110,13 @@ static char *of_overlay_fix_path(struct device_node *root,
break;
}
if (!fragment) {
- pr_info("could not find __overlay__ node\n");
+ pr_debug("could not find __overlay__ node for %s\n", path);
return NULL;
}
target = find_target(root, fragment, false);
if (!target)
- return NULL;
+ return ERR_PTR(-EINVAL);
prefix = of_get_child_by_name(fragment, "__overlay__")->full_name;
path_tail = path + strlen(prefix);
@@ -152,8 +152,10 @@ static int of_overlay_apply_symbols(struct device_node *root,
old_path = of_property_get_value(prop);
new_path = of_overlay_fix_path(root, overlay, old_path);
+ if (IS_ERR(new_path))
+ return PTR_ERR(new_path);
if (!new_path)
- return -EINVAL;
+ continue;
pr_debug("add symbol %s with new path %s\n",
prop->name, new_path);
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 2/2] of: overlay: fix_path/apply_symbols: add more debugging calls
2026-10-14 15:09 [PATCH 0/2] of: overlay: of_overlay_fix_path: allow symbols without __overlay__ Stefan Kerkmann
2026-10-14 15:09 ` [PATCH 1/2] " Stefan Kerkmann
@ 2026-10-14 15:09 ` Stefan Kerkmann
2026-10-15 11:03 ` [PATCH 0/2] of: overlay: of_overlay_fix_path: allow symbols without __overlay__ Stefan Kerkmann
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Kerkmann @ 2026-10-14 15:09 UTC (permalink / raw)
To: Sascha Hauer, open list:BAREBOX; +Cc: Stefan Kerkmann
Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de>
---
drivers/of/overlay.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
index 410c6d3565..83c947d044 100644
--- a/drivers/of/overlay.c
+++ b/drivers/of/overlay.c
@@ -114,6 +114,8 @@ static char *of_overlay_fix_path(struct device_node *root,
return NULL;
}
+ pr_debug("using fragment %pOF\n", fragment);
+
target = find_target(root, fragment, false);
if (!target)
return ERR_PTR(-EINVAL);
@@ -157,8 +159,8 @@ static int of_overlay_apply_symbols(struct device_node *root,
if (!new_path)
continue;
- pr_debug("add symbol %s with new path %s\n",
- prop->name, new_path);
+ pr_debug("add symbol %s with new path %s (was %s)\n",
+ prop->name, new_path, old_path);
of_property_write_string(root_symbols, prop->name, new_path);
free(new_path);
}
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 0/2] of: overlay: of_overlay_fix_path: allow symbols without __overlay__
2026-10-14 15:09 [PATCH 0/2] of: overlay: of_overlay_fix_path: allow symbols without __overlay__ Stefan Kerkmann
2026-10-14 15:09 ` [PATCH 1/2] " Stefan Kerkmann
2026-10-14 15:09 ` [PATCH 2/2] of: overlay: fix_path/apply_symbols: add more debugging calls Stefan Kerkmann
@ 2026-10-15 11:03 ` Stefan Kerkmann
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Kerkmann @ 2026-10-15 11:03 UTC (permalink / raw)
To: Sascha Hauer, open list:BAREBOX
Hi Sascha,
I'll sent a V2 shortly which adds self tests and one more fix. Please don't apply.
On 10/14/26 17:09, Stefan Kerkmann wrote:
> Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de>
> ---
> Stefan Kerkmann (2):
> of: overlay: of_overlay_fix_path: allow symbols without __overlay__
> of: overlay: fix_path/apply_symbols: add more debugging calls
>
> drivers/of/overlay.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
> ---
> base-commit: e82842ffe3c7993dac4f8493fb4a44c4d35810ca
> change-id: 20261014-fix-overlay-b53fbdff8ddc
>
> Best regards,
> --
> Stefan Kerkmann <s.kerkmann@pengutronix.de>
Best regards,
Stefan
--
Pengutronix e.K. | Stefan Kerkmann |
Steuerwalder Str. 21 | https://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-128 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
^ permalink raw reply [flat|nested] 4+ messages in thread