diff options
author | Ye Li <ye.li@nxp.com> | 2020-08-02 19:43:14 -0700 |
---|---|---|
committer | Ye Li <ye.li@nxp.com> | 2020-08-04 03:17:17 -0700 |
commit | cfb4e1919db16c5e0de05638032f09674d756350 (patch) | |
tree | 266b581a5658ec71ccb759548906cc2fd4ab3bc4 | |
parent | 72e8bfaec05d804d574d72edec175de0004e5fd8 (diff) |
LF-1858 mmc: fsl_esdhc_imx: Fix resource leak
Fix Coverity Issue 5498427. In fsl_esdhc_initialize, leak of memory to
system resource variable 'plat'. Move the fuse check to the beginning
of the function before the resources allocation.
Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
-rw-r--r-- | drivers/mmc/fsl_esdhc_imx.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c index 3044c9cf33..fd6b684682 100644 --- a/drivers/mmc/fsl_esdhc_imx.c +++ b/drivers/mmc/fsl_esdhc_imx.c @@ -1312,6 +1312,13 @@ int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg) if (!cfg) return -EINVAL; +#ifdef CONFIG_MX6 + if (mx6_esdhc_fused(cfg->esdhc_base)) { + printf("ESDHC@0x%lx is fused, disable it\n", cfg->esdhc_base); + return -ENODEV; + } +#endif + priv = calloc(sizeof(struct fsl_esdhc_priv), 1); if (!priv) return -ENOMEM; @@ -1329,14 +1336,6 @@ int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg) return ret; } -#ifdef CONFIG_MX6 - if (mx6_esdhc_fused(cfg->esdhc_base)) { - printf("ESDHC@0x%lx is fused, disable it\n", cfg->esdhc_base); - free(priv); - return -ENODEV; - } -#endif - ret = fsl_esdhc_init(priv, plat); if (ret) { debug("%s init failure\n", __func__); |