[PATCH 11/31] mmc: sdhci-msm: fix potential mem leak in sdhci_msm_probe()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We should use dev_pm_opp_put_clkname() to free opp table each time
dev_pm_opp_of_add_table() got error.

Signed-off-by: Yangtao Li <tiny.windzz@xxxxxxxxx>
---
 drivers/mmc/host/sdhci-msm.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 9c7927b03253..094ef95f5ecc 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -2291,9 +2291,12 @@ static int sdhci_msm_probe(struct platform_device *pdev)
 
 	/* OPP table is optional */
 	ret = dev_pm_opp_of_add_table(&pdev->dev);
-	if (ret && ret != -ENODEV) {
-		dev_err(&pdev->dev, "Invalid OPP table in Device tree\n");
-		goto opp_put_clkname;
+	if (ret) {
+		dev_pm_opp_put_clkname(msm_host->opp_table);
+		if (ret != -ENODEV) {
+			dev_err(&pdev->dev, "Invalid OPP table in Device tree\n");
+			goto bus_clk_disable;
+		}
 	}
 
 	/* Vote for maximum clock rate for maximum performance */
@@ -2461,7 +2464,6 @@ static int sdhci_msm_probe(struct platform_device *pdev)
 				   msm_host->bulk_clks);
 opp_cleanup:
 	dev_pm_opp_of_remove_table(&pdev->dev);
-opp_put_clkname:
 	dev_pm_opp_put_clkname(msm_host->opp_table);
 bus_clk_disable:
 	if (!IS_ERR(msm_host->bus_clk))
-- 
2.25.1




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux