[PATCH] environment: don't return raw device when file-path is specified
Lucas Stach
dev at lynxeye.de
Fri Dec 13 07:08:55 PST 2024
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 at 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
More information about the barebox
mailing list