environment: don't return raw device when file-path is specified
PATCH 1/1 environment: don't return raw device when file-path is specified
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.
--- drivers/of/barebox.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/of/barebox.c +5 -4
@@ -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;
Signature · 1 line
2.47.1
Sascha Hauer
AppliedQuoted 9 lines · Lucas Stach
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_FSis 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,
Signature · 1 line
Sascha Hauer <[email protected]>