mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master] of: base: handle of_set_root_node(NULL) correctly
@ 2026-05-20 13:49 Ahmad Fatoum
  2026-05-20 14:14 ` Alexander Shiyan
  2026-05-21  8:39 ` Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2026-05-20 13:49 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum, Alexander Shiyan

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@gmail.com>
Signed-off-by: Ahmad Fatoum <a.fatoum@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




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

* Re: [PATCH master] of: base: handle of_set_root_node(NULL) correctly
  2026-05-20 13:49 [PATCH master] of: base: handle of_set_root_node(NULL) correctly Ahmad Fatoum
@ 2026-05-20 14:14 ` Alexander Shiyan
  2026-05-21  8:39 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Shiyan @ 2026-05-20 14:14 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

Tested-by: Alexander Shiyan <eagle.alexander923@gmail.com>

ср, 20 мая 2026 г. в 16:49, Ahmad Fatoum <a.fatoum@pengutronix.de>:
>
> 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@gmail.com>
> Signed-off-by: Ahmad Fatoum <a.fatoum@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
>



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

* Re: [PATCH master] of: base: handle of_set_root_node(NULL) correctly
  2026-05-20 13:49 [PATCH master] of: base: handle of_set_root_node(NULL) correctly Ahmad Fatoum
  2026-05-20 14:14 ` Alexander Shiyan
@ 2026-05-21  8:39 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2026-05-21  8:39 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum; +Cc: Alexander Shiyan


On Wed, 20 May 2026 15:49:06 +0200, Ahmad Fatoum wrote:
> 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.
> 
> 
> [...]

Applied, thanks!

[1/1] of: base: handle of_set_root_node(NULL) correctly
      https://git.pengutronix.de/cgit/barebox/commit/?id=031e0f514d8d (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




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

end of thread, other threads:[~2026-05-21  8:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-20 13:49 [PATCH master] of: base: handle of_set_root_node(NULL) correctly Ahmad Fatoum
2026-05-20 14:14 ` Alexander Shiyan
2026-05-21  8:39 ` Sascha Hauer

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