tools: env: return error if ubi_update_start() fails
authorMartin Hundebøll <martin@geanix.com>
Mon, 30 Nov 2020 11:11:32 +0000 (12:11 +0100)
committerTom Rini <trini@konsulko.com>
Fri, 22 Jan 2021 21:58:55 +0000 (16:58 -0500)
The UBI_IOCVOLUP ioctl can fail if exclusive access to the volume isn't
obtained. If this happens, the flush operation doesn't return error,
leaving the caller without knowledge of missing flush.

Fix this by forwarding the error (-1) from ubi_update_start().

Fixes: 34255b92e6e ("tools: env: Add support for direct read/write UBI volumes")
Signed-off-by: Martin Hundebøll <martin@geanix.com>
tools/env/fw_env.c

index 66cb9d2..2a61a5d 100644 (file)
@@ -1208,7 +1208,7 @@ static int flash_write(int fd_current, int fd_target, int dev_target)
 
        if (IS_UBI(dev_target)) {
                if (ubi_update_start(fd_target, CUR_ENVSIZE) < 0)
-                       return 0;
+                       return -1;
                return ubi_write(fd_target, environment.image, CUR_ENVSIZE);
        }