diff mbox series

clk: ti: dra7-atl: Fix reference leak in of_dra7_atl_clk_probe

Message ID 20220602030838.52057-1-linmq006@gmail.com (mailing list archive)
State New, archived
Headers show
Series clk: ti: dra7-atl: Fix reference leak in of_dra7_atl_clk_probe | expand

Commit Message

Miaoqian Lin June 2, 2022, 3:08 a.m. UTC
pm_runtime_get_sync() will increment pm usage counter.
Forgetting to putting operation will result in reference leak.
Add missing pm_runtime_put_sync in some error paths.

Fixes: 9ac33b0ce81f ("CLK: TI: Driver for DRA7 ATL (Audio Tracking Logic)")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/clk/ti/clk-dra7-atl.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Tony Lindgren June 28, 2022, 5:20 a.m. UTC | #1
* Miaoqian Lin <linmq006@gmail.com> [220602 06:04]:
> pm_runtime_get_sync() will increment pm usage counter.
> Forgetting to putting operation will result in reference leak.
> Add missing pm_runtime_put_sync in some error paths.
> 
> Fixes: 9ac33b0ce81f ("CLK: TI: Driver for DRA7 ATL (Audio Tracking Logic)")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>

Reviewed-by: Tony Lindgren <tony@atomide.com>
Stephen Boyd Oct. 1, 2022, 12:40 a.m. UTC | #2
Quoting Miaoqian Lin (2022-06-01 20:08:36)
> pm_runtime_get_sync() will increment pm usage counter.
> Forgetting to putting operation will result in reference leak.
> Add missing pm_runtime_put_sync in some error paths.
> 
> Fixes: 9ac33b0ce81f ("CLK: TI: Driver for DRA7 ATL (Audio Tracking Logic)")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---

Applied to clk-next
diff mbox series

Patch

diff --git a/drivers/clk/ti/clk-dra7-atl.c b/drivers/clk/ti/clk-dra7-atl.c
index aa0950c4f498..5c278d6c985e 100644
--- a/drivers/clk/ti/clk-dra7-atl.c
+++ b/drivers/clk/ti/clk-dra7-atl.c
@@ -253,14 +253,16 @@  static int of_dra7_atl_clk_probe(struct platform_device *pdev)
 		if (rc) {
 			pr_err("%s: failed to lookup atl clock %d\n", __func__,
 			       i);
-			return -EINVAL;
+			ret = -EINVAL;
+			goto pm_put;
 		}
 
 		clk = of_clk_get_from_provider(&clkspec);
 		if (IS_ERR(clk)) {
 			pr_err("%s: failed to get atl clock %d from provider\n",
 			       __func__, i);
-			return PTR_ERR(clk);
+			ret = PTR_ERR(clk);
+			goto pm_put;
 		}
 
 		cdesc = to_atl_desc(__clk_get_hw(clk));
@@ -293,8 +295,9 @@  static int of_dra7_atl_clk_probe(struct platform_device *pdev)
 		if (cdesc->enabled)
 			atl_clk_enable(__clk_get_hw(clk));
 	}
-	pm_runtime_put_sync(cinfo->dev);
 
+pm_put:
+	pm_runtime_put_sync(cinfo->dev);
 	return ret;
 }