Skip to contentSkip to conversation

clk: starfive: jh7110-isp: fix refcount leak in jh7110_ispcrg_probe()

PATCH Applied Wentao Liang 3 participants 3 messages Jun 4 – Sep 29

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

PATCH 1/1 clk: starfive: jh7110-isp: fix refcount leak in jh7110_ispcrg_probe()

In jh7110_ispcrg_probe(), the error path for pm_runtime_get_sync() failure directly returns without releasing the runtime PM reference count. The call to __pm_runtime_resume() increments the usage count unconditionally before attempting to resume, and does not decrement it on failure. Thus the leaked reference makes it impossible to suspend the device later.

All other error paths correctly jump to err_exit and call pm_runtime_put_sync(). Fix this by replacing pm_runtime_get_sync() with pm_runtime_resume_and_get(), which properly balances the reference count on error.

Fixes 81279f5d0812 ("clk: starfive: Add StarFive JH7110 Image-Signal-Process clock driver")
---
 drivers/clk/starfive/clk-starfive-jh7110-isp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/starfive/clk-starfive-jh7110-isp.c +1 -1
index f3fa069db193..c02c8b29a123 100644
@@ -130,7 +130,7 @@ 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);
+	ret = pm_runtime_resume_and_get(priv->dev);
 	if (ret < 0)
 		return dev_err_probe(priv->dev, ret, "failed to turn on power\n");
 
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 25 lines · Wentao Liang

In jh7110_ispcrg_probe(), the error path for pm_runtime_get_sync() failure directly returns without releasing the runtime PM reference count. The call to __pm_runtime_resume() increments the usage count unconditionally before attempting to resume, and does not decrement it on failure. Thus the leaked reference makes it impossible to suspend the device later.

All other error paths correctly jump to err_exit and call pm_runtime_put_sync(). Fix this by replacing pm_runtime_get_sync() with pm_runtime_resume_and_get(), which properly balances the reference count on error.

Fixes 81279f5d0812 ("clk: starfive: Add StarFive JH7110 Image-Signal-Process

clock driver")

---
 drivers/clk/starfive/clk-starfive-jh7110-isp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/starfive/clk-starfive-jh7110-isp.c +0 -0
index f3fa069db193..c02c8b29a123 100644

drivers/clk/starfive/clk-starfive-jh7110-isp.c static int jh7110_ispcrg_probe(struct platform_device · line 136

Quoted 8 lines
drivers/clk/starfive/clk-starfive-jh7110-isp.c +1 -1
@@ -130,7 +130,7 @@ 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);
+	ret = pm_runtime_resume_and_get(priv->dev);
 	if (ret < 0)
 		return dev_err_probe(priv->dev, ret, "failed to turn on power\n");

Looks good. Keep it consistent with drivers/clk/starfive/clk-starfive-jh7110-vout.c.

Best regards,
Hal

Applied
#2 lore raw
In reply to Wentao Liang
Quoted 1 line · Wentao Liang

clk: starfive: jh7110-isp: fix refcount leak in jh7110_ispcrg_probe()

Applied, thanks!

[1/1] clk: starfive: jh7110-isp: fix refcount leak in jh7110_ispcrg_probe()

      commit: 1c4f9480473917558908c083d1293b4ebb3d50c5

Best regards,

Signature · 1 line
Brian Masney <[email protected]>