From: Lucas Stach <dev@lynxeye.de>
To: barebox@lists.infradead.org
Subject: [PATCH] environment: don't return raw device when file-path is specified
Date: Fri, 13 Dec 2024 16:08:55 +0100 [thread overview]
Message-ID: <20241213150855.263388-1-dev@lynxeye.de> (raw)
Environment nodes that specify the file-path property expect the
environment to be stored in a file system.
Returning the raw device path when CONFIG_OF_BAREBOX_ENV_IN_FS is
disabled in such a case is not a good idea, as saving the env may
then unexpectedly overwrite unrelated device content. Bail out in
case a file-path is specified, but we have no env in FS support.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
drivers/of/barebox.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/of/barebox.c b/drivers/of/barebox.c
index dc90c0cb3ada..9b8da679e2cd 100644
--- a/drivers/of/barebox.c
+++ b/drivers/of/barebox.c
@@ -42,13 +42,14 @@ static char *environment_probe_2node_binding(struct device *dev)
if (ret)
goto out;
- if (!IS_ENABLED(CONFIG_OF_BAREBOX_ENV_IN_FS))
+ if (!of_property_present(dev->of_node, "file-path"))
return devpath;
+ if (!IS_ENABLED(CONFIG_OF_BAREBOX_ENV_IN_FS))
+ return ERR_PTR(-ENOENT);
+
ret = of_property_read_string(dev->of_node, "file-path", &filepath);
- if (ret == -EINVAL) {
- return devpath;
- } else if (ret) {
+ if (ret) {
/* file-path property exists, but has error */
dev_err(dev, "Problem with file-path property\n");
goto out;
--
2.47.1
next reply other threads:[~2024-12-13 15:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-13 15:08 Lucas Stach [this message]
2024-12-20 9:04 ` 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=20241213150855.263388-1-dev@lynxeye.de \
--to=dev@lynxeye.de \
--cc=barebox@lists.infradead.org \
/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