[U-Boot] [PATCH] mmc: fsl_esdhc: Check the result from malloc()

Fabio Estevam fabio.estevam at freescale.com
Thu Sep 12 15:35:52 CEST 2013


malloc can fail, so we should better check its return value before using it.

Signed-off-by: Fabio Estevam <fabio.estevam at freescale.com>
---
 drivers/mmc/fsl_esdhc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index f87e647..a7170b4 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -518,6 +518,8 @@ int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg)
 		return -1;
 
 	mmc = malloc(sizeof(struct mmc));
+	if (!mmc)
+		return -ENOMEM;
 
 	sprintf(mmc->name, "FSL_SDHC");
 	regs = (struct fsl_esdhc *)cfg->esdhc_base;
-- 
1.8.1.2




More information about the U-Boot mailing list