mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 1/2] of: refuse to delete root node of live tree
Date: Fri, 25 Jun 2021 16:02:05 +0200	[thread overview]
Message-ID: <20210625140206.2000-1-s.hauer@pengutronix.de> (raw)

The root node of the live tree should never be deleted, so refuse to do
so and print an error message. Deleting the live tree was possible with
the oftree -f command which was removed in c39c70bac5 ("commands: oftree:
kill oftree -f"). As this no longer exists we also do not need the
of_set_root_node(NULL) part anymore.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/of/base.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 5756f8b60a..551b41fc9e 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2441,6 +2441,11 @@ void of_delete_node(struct device_node *node)
 	if (!node)
 		return;
 
+	if (node == root_node) {
+		pr_err("Won't delete root device node\n");
+		return;
+	}
+
 	list_for_each_entry_safe(p, pt, &node->properties, list)
 		of_delete_property(p);
 
@@ -2459,9 +2464,6 @@ void of_delete_node(struct device_node *node)
 	free(node->name);
 	free(node->full_name);
 	free(node);
-
-	if (node == root_node)
-		of_set_root_node(NULL);
 }
 
 struct device_node *of_get_stdoutpath(void)
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


             reply	other threads:[~2021-06-25 14:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-25 14:02 Sascha Hauer [this message]
2021-06-25 14:02 ` [PATCH 2/2] of: Fix deep-probe triggering when removing nodes 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=20210625140206.2000-1-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --subject='Re: [PATCH 1/2] of: refuse to delete root node of live tree' \
    /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

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