mmc: fsl_esdhc: Check the result from malloc()
authorFabio Estevam <fabio.estevam@freescale.com>
Thu, 12 Sep 2013 13:35:52 +0000 (10:35 -0300)
committerStefano Babic <sbabic@denx.de>
Fri, 20 Sep 2013 15:55:36 +0000 (17:55 +0200)
malloc can fail, so we should better check its return value before using it.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
drivers/mmc/fsl_esdhc.c

index f87e647881cce82f2eac37a4fc5a4863072b82e2..a7170b49db384ff20a0276eb03312192d993f1a6 100644 (file)
@@ -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;