Skip to contentSkip to conversation

mmc: fsl_esdhc: Check the result from malloc()

PATCH New Fabio Estevam 2 participants 2 messages Sep 12, 2013 – Sep 20, 2013 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: fsl_esdhc: Check the result from malloc()

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

---
 drivers/mmc/fsl_esdhc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mmc/fsl_esdhc.c +2 -0
index f87e647..a7170b4 100644
@@ -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;
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 1/1 mmc: fsl_esdhc: Check the result from malloc()

Quoted 4 lines · Fabio Estevam

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

---

Applied to u-boot-imx, thanks!

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================