diff mbox series

tools: env: return error if ubi_update_start() fails

Message ID 20201130111132.2870658-1-martin@geanix.com
State Accepted
Commit 09779488a924dbc4eb3b4ae145632f22b7f5a36c
Delegated to: Tom Rini
Headers show
Series tools: env: return error if ubi_update_start() fails | expand

Commit Message

Martin Hundebøll Nov. 30, 2020, 11:11 a.m. UTC
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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Tom Rini Jan. 23, 2021, 5:45 p.m. UTC | #1
On Mon, Nov 30, 2020 at 12:11:32PM +0100, Martin Hundebøll wrote:

> 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>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 66cb9d2a25..2a61a5d6f0 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -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);
 	}