]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
board: freescale: Fix error handling in ls1088a board setup
authorFrancois Berder <fberder@outlook.fr>
Sat, 22 Nov 2025 12:26:07 +0000 (13:26 +0100)
committerPeng Fan <peng.fan@nxp.com>
Thu, 11 Dec 2025 10:42:21 +0000 (18:42 +0800)
 - Add missing checks after calloc
 - Fix memory leak when handling calloc failure

Signed-off-by: Francois Berder <fberder@outlook.fr>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
board/freescale/ls1088a/ls1088a.c

index 9606434e8ffc9c1e7f96283938625017826d7c5f..51ec055be63a8160e26e1e2efe193091a403effe 100644 (file)
@@ -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++) {