[PATCH] clk: starfive: jh7110-isp: fix pm_runtime error handling

phucduc.bui@gmail.com posted 1 patch 6 days, 19 hours ago
drivers/clk/starfive/clk-starfive-jh7110-isp.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
[PATCH] clk: starfive: jh7110-isp: fix pm_runtime error handling
Posted by phucduc.bui@gmail.com 6 days, 19 hours ago
From: bui duc phuc <phucduc.bui@gmail.com>

pm_runtime_get_sync() leaves the runtime PM usage counter incremented even
when it fails, but the error path in jh7110_ispcrg_probe() does not call
pm_runtime_put_noidle() to balance it, leaking a reference each time
resume fails.

Use pm_runtime_resume_and_get() instead, which automatically drops the
usage counter on failure, fixing the leak.

Also disable runtime PM before returning from the error path to balance
the pm_runtime_enable() call.

Fixes: 81279f5d0812 ("clk: starfive: Add StarFive JH7110 Image-Signal-Process clock driver")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
 drivers/clk/starfive/clk-starfive-jh7110-isp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/starfive/clk-starfive-jh7110-isp.c b/drivers/clk/starfive/clk-starfive-jh7110-isp.c
index f3fa069db193..860c9ec897e8 100644
--- a/drivers/clk/starfive/clk-starfive-jh7110-isp.c
+++ b/drivers/clk/starfive/clk-starfive-jh7110-isp.c
@@ -130,9 +130,11 @@ static int jh7110_ispcrg_probe(struct platform_device *pdev)
 
 	/* enable power domain and clocks */
 	pm_runtime_enable(priv->dev);
-	ret = pm_runtime_get_sync(priv->dev);
-	if (ret < 0)
+	ret = pm_runtime_resume_and_get(priv->dev);
+	if (ret < 0) {
+		pm_runtime_disable(priv->dev);
 		return dev_err_probe(priv->dev, ret, "failed to turn on power\n");
+	}
 
 	ret = jh7110_isp_top_rst_init(priv);
 	if (ret)
-- 
2.43.0