Skip to contentSkip to conversation

mmc: free allocated memory on initialization errors

PATCH New Darwin Rambo 2 participants 2 messages May 26, 2014 – Jun 12, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: free allocated memory on initialization errors

Cleanup to balance malloc/free calls.

---

 drivers/mmc/kona_sdhci.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/mmc/kona_sdhci.c +6 -2
index 77e42c8..f804f4c 100644
@@ -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;
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 mmc: free allocated memory on initialization errors

Hi Darwin

Quoted 39 lines · Darwin Rambo

Cleanup to balance malloc/free calls.

---

drivers/mmc/kona_sdhci.c | 8 ++++++--

1 file changed, 6 insertions(+), 2 deletions(-)
drivers/mmc/kona_sdhci.c +6 -2
index 77e42c8..f804f4c 100644
@@ -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;
Signature · 1 line
1.7.9.5

Thanks, applied.

-- Pantelis