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>
This commit is contained in:
parent
0469d84636
commit
d5b8500f03
@ -176,8 +176,7 @@ static int iproc_sdhci_probe(struct udevice *dev)
|
|||||||
u32 f_min_max[2];
|
u32 f_min_max[2];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
iproc_host = (struct sdhci_iproc_host *)
|
iproc_host = malloc(sizeof(struct sdhci_iproc_host));
|
||||||
malloc(sizeof(struct sdhci_iproc_host));
|
|
||||||
if (!iproc_host) {
|
if (!iproc_host) {
|
||||||
printf("%s: sdhci host malloc fail!\n", __func__);
|
printf("%s: sdhci host malloc fail!\n", __func__);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
@ -198,6 +197,7 @@ static int iproc_sdhci_probe(struct udevice *dev)
|
|||||||
"clock-freq-min-max", f_min_max, 2);
|
"clock-freq-min-max", f_min_max, 2);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printf("sdhci: clock-freq-min-max not found\n");
|
printf("sdhci: clock-freq-min-max not found\n");
|
||||||
|
free(iproc_host);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
host->max_clk = f_min_max[1];
|
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,
|
ret = sdhci_setup_cfg(&plat->cfg, &iproc_host->host,
|
||||||
f_min_max[1], f_min_max[0]);
|
f_min_max[1], f_min_max[0]);
|
||||||
if (ret)
|
if (ret) {
|
||||||
|
free(iproc_host);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
iproc_host->host.mmc = &plat->mmc;
|
iproc_host->host.mmc = &plat->mmc;
|
||||||
iproc_host->host.mmc->dev = dev;
|
iproc_host->host.mmc->dev = dev;
|
||||||
|
Loading…
Reference in New Issue
Block a user