[PATCH] board: freescale: Fix error handling in ls1088a board setup

Francois Berder fberder at outlook.fr
Sat Nov 22 13:26:07 CET 2025


  - Add missing checks after calloc
  - Fix memory leak when handling calloc failure

Signed-off-by: Francois Berder <fberder at outlook.fr>
---
 board/freescale/ls1088a/ls1088a.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/board/freescale/ls1088a/ls1088a.c b/board/freescale/ls1088a/ls1088a.c
index 9606434e8ff..51ec055be63 100644
--- a/board/freescale/ls1088a/ls1088a.c
+++ b/board/freescale/ls1088a/ls1088a.c
@@ -948,7 +948,14 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 	total_memory_banks = CONFIG_NR_DRAM_BANKS + mc_memory_bank;
 
 	base = calloc(total_memory_banks, sizeof(u64));
+	if (!base)
+		return -ENOMEM;
+
 	size = calloc(total_memory_banks, sizeof(u64));
+	if (!size) {
+		free(base);
+		return -ENOMEM;
+	}
 
 	/* fixup DT for the two GPP DDR banks */
 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
-- 
2.43.0



More information about the U-Boot mailing list