[PATCH] cmd: onenand: Fix handling error path in onenand_block_test

Francois Berder fberder at outlook.fr
Thu Dec 18 07:48:51 CET 2025


If memory allocation for verify_buf fails, then one
needs to make sure that memory allocated for buf is
released.

Signed-off-by: Francois Berder <fberder at outlook.fr>
---
 cmd/onenand.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/cmd/onenand.c b/cmd/onenand.c
index 6e808ce3fce..90f4f52f4af 100644
--- a/cmd/onenand.c
+++ b/cmd/onenand.c
@@ -236,6 +236,7 @@ static int onenand_block_test(u32 start, u32 size)
 
 	verify_buf = malloc(blocksize);
 	if (!verify_buf) {
+		free(buf);
 		printf("Not enough malloc space available!\n");
 		return -1;
 	}
-- 
2.43.0



More information about the U-Boot mailing list