[PATCH] arch: imx9: Fix blk_dwrite/blk_derase error checking

Francois Berder fberder at outlook.fr
Sun May 24 22:35:59 CEST 2026


blk_dwrite/blk_derase returns the number of blocks
written/erased. The existing check allowed partial
writes or partial erase to be considered successful.
Fix error handling of blk_dwrite/blk_derase by checking
that return value corresponds to the number of blocks
written/erased.

Signed-off-by: Francois Berder <fberder at outlook.fr>
---
 arch/arm/mach-imx/imx9/qb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-imx/imx9/qb.c b/arch/arm/mach-imx/imx9/qb.c
index 1a0a12de3d4..4f73db8e594 100644
--- a/arch/arm/mach-imx/imx9/qb.c
+++ b/arch/arm/mach-imx/imx9/qb.c
@@ -304,8 +304,8 @@ static int imx_qb_blk(const char * const ifname,
 		ret = blk_derase(bdesc, offset, load_size);
 	}
 
-	if (!ret) {
-		printf("Failed to write to block device\n");
+	if (ret != load_size) {
+		printf("Failed to %s block device\n", save ? "write to" : "erase");
 		return -EIO;
 	}
 
-- 
2.43.0



More information about the U-Boot mailing list