[U-Boot] arm64: zynqmp: Check return value from calloc

Message ID d299c9a7dbf24ab3d7944abf576ccd94afd9e45b.1528875844.git.michal.simek@xilinx.com
State New
Delegated to: Michal Simek
Headers show
Series
  • [U-Boot] arm64: zynqmp: Check return value from calloc
Related show

Commit Message

Michal Simek June 13, 2018, 7:44 a.m.
calloc() can fail and return NULL. The patch is checking return value
and return in case of error.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 board/xilinx/zynqmp/zynqmp.c | 2 ++
 1 file changed, 2 insertions(+)

Patch

diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
index 3e8edb81109a..68a0964477e0 100644
--- a/board/xilinx/zynqmp/zynqmp.c
+++ b/board/xilinx/zynqmp/zynqmp.c
@@ -624,6 +624,8 @@  int board_late_init(void)
 
 	new_targets = calloc(1, strlen(mode) + env_targets_len + 2 +
 			     bootseq_len);
+	if (!new_targets)
+		return -ENOMEM;
 
 	if (bootseq >= 0)
 		sprintf(new_targets, "%s%x %s", mode, bootseq,