* [PATCH] environment: don't return raw device when file-path is specified
@ 2024-12-13 15:08 Lucas Stach
2024-12-20 9:04 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Lucas Stach @ 2024-12-13 15:08 UTC (permalink / raw)
To: barebox
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] environment: don't return raw device when file-path is specified
2024-12-13 15:08 [PATCH] environment: don't return raw device when file-path is specified Lucas Stach
@ 2024-12-20 9:04 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-12-20 9:04 UTC (permalink / raw)
To: barebox, Lucas Stach
On Fri, 13 Dec 2024 16:08:55 +0100, Lucas Stach wrote:
> 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.
>
> [...]
Applied, thanks!
[1/1] environment: don't return raw device when file-path is specified
https://git.pengutronix.de/cgit/barebox/commit/?id=f4283f6d9f15 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-12-20 9:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-13 15:08 [PATCH] environment: don't return raw device when file-path is specified Lucas Stach
2024-12-20 9:04 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox