[PATCH master] of: base: handle of_set_root_node(NULL) correctly
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed May 20 06:49:06 PDT 2026
of_set_root_node(NULL) used to be valid and the if clause at the start
of the function explicitly allowed of it.
This was broken by the unconditional use of of_property_write_bool, so
guard that behind the existence of a root node.
Fixes: b1ced2c3caa9 ("state: suppress state overwrite warning for barebox DT")
Reported-by: Alexander Shiyan <eagle.alexander923 at gmail.com>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
drivers/of/base.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index d4fbd2367baf..57b64bc0b96c 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2123,15 +2123,17 @@ int of_set_root_node(struct device_node *node)
if (node && root_node)
return -EBUSY;
root_node = node;
of_chosen = of_find_node_by_path("/chosen");
of_property_read_string(root_node, "model", &of_model);
- of_property_write_bool(root_node, "$barebox,root-node", true);
+
+ if (root_node)
+ of_property_write_bool(root_node, "$barebox,root-node", true);
if (of_model)
barebox_set_model(of_model);
of_alias_scan();
return 0;
--
2.47.3
More information about the barebox
mailing list