aboutsummaryrefslogtreecommitdiff
path: root/drivers/mmc
diff options
context:
space:
mode:
authorBharat Kumar Reddy Gooty <bharat.gooty@broadcom.com>2020-03-31 11:04:03 +0530
committerPeng Fan <peng.fan@nxp.com>2020-04-22 20:41:55 +0800
commitd5b8500f033fd14c3ab6e66417ce8c819f7889db (patch)
tree63d0b296d07c3ea47645a471a362cb744ef407b5 /drivers/mmc
parent0469d846364ae54fc380a813cc4c3e9e19bdc99a (diff)
downloadu-boot-d5b8500f033fd14c3ab6e66417ce8c819f7889db.zip
u-boot-d5b8500f033fd14c3ab6e66417ce8c819f7889db.tar.gz
u-boot-d5b8500f033fd14c3ab6e66417ce8c819f7889db.tar.bz2
drivers: mmc: iproc_sdhci: fix possible memory leak
Free the pointer variable 'iproc_sdhci' upon failure to fix possible memory leak. Signed-off-by: Bharat Kumar Reddy Gooty <bharat.gooty@broadcom.com> Signed-off-by: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/iproc_sdhci.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/mmc/iproc_sdhci.c b/drivers/mmc/iproc_sdhci.c
index 831dd32..36ecdba 100644
--- a/drivers/mmc/iproc_sdhci.c
+++ b/drivers/mmc/iproc_sdhci.c
@@ -176,8 +176,7 @@ static int iproc_sdhci_probe(struct udevice *dev)
u32 f_min_max[2];
int ret;
- iproc_host = (struct sdhci_iproc_host *)
- malloc(sizeof(struct sdhci_iproc_host));
+ iproc_host = malloc(sizeof(struct sdhci_iproc_host));
if (!iproc_host) {
printf("%s: sdhci host malloc fail!\n", __func__);
return -ENOMEM;
@@ -198,6 +197,7 @@ static int iproc_sdhci_probe(struct udevice *dev)
"clock-freq-min-max", f_min_max, 2);
if (ret) {
printf("sdhci: clock-freq-min-max not found\n");
+ free(iproc_host);
return ret;
}
host->max_clk = f_min_max[1];
@@ -212,8 +212,10 @@ static int iproc_sdhci_probe(struct udevice *dev)
ret = sdhci_setup_cfg(&plat->cfg, &iproc_host->host,
f_min_max[1], f_min_max[0]);
- if (ret)
+ if (ret) {
+ free(iproc_host);
return ret;
+ }
iproc_host->host.mmc = &plat->mmc;
iproc_host->host.mmc->dev = dev;