diff mbox series

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

Message ID 20210101165507.19486-12-tiny.windzz@gmail.com (mailing list archive)
State New, archived
Delegated to: viresh kumar
Headers show
Series Introduce devm_pm_opp_* API | expand

Commit Message

Yangtao Li Jan. 1, 2021, 4:54 p.m. UTC
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@gmail.com>
---
 drivers/mmc/host/sdhci-msm.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff mbox series

Patch

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))