[U-Boot] [PATCH] fw_env: Add missing write failure check

If flash_write fails, whilst we propagate this up to our caller, we need to avoid swapping in the new file (if we're on a filesystem) in this case.
Fixes: dbc34323796b ("tools: env: Implement atomic replace for filesystem") Signed-off-by: Alex Kiernan alex.kiernan@gmail.com ---
tools/env/fw_env.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c index cfada0ee1157..eef12dd2b757 100644 --- a/tools/env/fw_env.c +++ b/tools/env/fw_env.c @@ -1317,7 +1317,7 @@ static int flash_io_write(int fd_current) rc = -1; }
- if (target_temp) { + if (rc >= 0 && target_temp) { int dir_fd;
dir_fd = open(dname, O_DIRECTORY | O_RDONLY);

On Wed, Jun 12, 2019 at 03:27:55PM +0100, Alex Kiernan wrote:
If flash_write fails, whilst we propagate this up to our caller, we need to avoid swapping in the new file (if we're on a filesystem) in this case.
Fixes: dbc34323796b ("tools: env: Implement atomic replace for filesystem") Signed-off-by: Alex Kiernan alex.kiernan@gmail.com
Applied to u-boot/master, thanks!
participants (2)
-
Alex Kiernan
-
Tom Rini