mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>,
	Alexander Shiyan <eagle.alexander923@gmail.com>
Subject: [PATCH master] of: base: handle of_set_root_node(NULL) correctly
Date: Wed, 20 May 2026 15:49:06 +0200	[thread overview]
Message-ID: <20260520134923.3233562-1-a.fatoum@pengutronix.de> (raw)

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




             reply	other threads:[~2026-05-20 13:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-20 13:49 Ahmad Fatoum [this message]
2026-05-20 14:14 ` Alexander Shiyan
2026-05-21  8:39 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260520134923.3233562-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=eagle.alexander923@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox