diff mbox

[U-Boot] mmc: free allocated memory on initialization errors

Message ID 1401136272-8611-1-git-send-email-drambo@broadcom.com
State Accepted
Delegated to: Pantelis Antoniou
Headers show

Commit Message

Darwin Rambo May 26, 2014, 8:31 p.m. UTC
Cleanup to balance malloc/free calls.

Signed-off-by: Darwin Rambo <drambo@broadcom.com>
Reviewed-by: Steve Rae <srae@broadcom.com>
---

 drivers/mmc/kona_sdhci.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Pantelis Antoniou June 12, 2014, 12:17 p.m. UTC | #1
Hi Darwin 

On May 26, 2014, at 11:31 PM, Darwin Rambo wrote:

> Cleanup to balance malloc/free calls.
> 
> Signed-off-by: Darwin Rambo <drambo@broadcom.com>
> Reviewed-by: Steve Rae <srae@broadcom.com>
> ---
> 
> drivers/mmc/kona_sdhci.c |    8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/kona_sdhci.c b/drivers/mmc/kona_sdhci.c
> index 77e42c8..f804f4c 100644
> --- a/drivers/mmc/kona_sdhci.c
> +++ b/drivers/mmc/kona_sdhci.c
> @@ -113,16 +113,20 @@ int kona_sdhci_init(int dev_index, u32 min_clk, u32 quirks)
> 		       __func__, dev_index);
> 		ret = -EINVAL;
> 	}
> -	if (ret)
> +	if (ret) {
> +		free(host);
> 		return ret;
> +	}
> 
> 	host->name = "kona-sdhci";
> 	host->ioaddr = reg_base;
> 	host->quirks = quirks;
> 	host->host_caps = MMC_MODE_HC;
> 
> -	if (init_kona_mmc_core(host))
> +	if (init_kona_mmc_core(host)) {
> +		free(host);
> 		return -EINVAL;
> +	}
> 
> 	if (quirks & SDHCI_QUIRK_REG32_RW)
> 		host->version = sdhci_readl(host, SDHCI_HOST_VERSION - 2) >> 16;
> -- 
> 1.7.9.5
> 

Thanks, applied.

-- Pantelis

Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>
diff mbox

Patch

diff --git a/drivers/mmc/kona_sdhci.c b/drivers/mmc/kona_sdhci.c
index 77e42c8..f804f4c 100644
--- a/drivers/mmc/kona_sdhci.c
+++ b/drivers/mmc/kona_sdhci.c
@@ -113,16 +113,20 @@  int kona_sdhci_init(int dev_index, u32 min_clk, u32 quirks)
 		       __func__, dev_index);
 		ret = -EINVAL;
 	}
-	if (ret)
+	if (ret) {
+		free(host);
 		return ret;
+	}
 
 	host->name = "kona-sdhci";
 	host->ioaddr = reg_base;
 	host->quirks = quirks;
 	host->host_caps = MMC_MODE_HC;
 
-	if (init_kona_mmc_core(host))
+	if (init_kona_mmc_core(host)) {
+		free(host);
 		return -EINVAL;
+	}
 
 	if (quirks & SDHCI_QUIRK_REG32_RW)
 		host->version = sdhci_readl(host, SDHCI_HOST_VERSION - 2) >> 16;