mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] clk: starfive: jh7110-isp: fix refcount leak in jh7110_ispcrg_probe()
@ 2026-06-04  6:43 Wentao Liang
  2026-06-16  3:10 ` Hal Feng
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-06-04  6:43 UTC (permalink / raw)
  To: kernel, hal.feng, mturquette, sboyd
  Cc: bmasney, linux-clk, linux-kernel, Wentao Liang, stable

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.

Cc: stable@vger.kernel.org
Fixes: 81279f5d0812 ("clk: starfive: Add StarFive JH7110 Image-Signal-Process clock driver")
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/clk/starfive/clk-starfive-jh7110-isp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/starfive/clk-starfive-jh7110-isp.c b/drivers/clk/starfive/clk-starfive-jh7110-isp.c
index f3fa069db193..c02c8b29a123 100644
--- a/drivers/clk/starfive/clk-starfive-jh7110-isp.c
+++ b/drivers/clk/starfive/clk-starfive-jh7110-isp.c
@@ -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");
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] clk: starfive: jh7110-isp: fix refcount leak in jh7110_ispcrg_probe()
  2026-06-04  6:43 [PATCH] clk: starfive: jh7110-isp: fix refcount leak in jh7110_ispcrg_probe() Wentao Liang
@ 2026-06-16  3:10 ` Hal Feng
  0 siblings, 0 replies; 2+ messages in thread
From: Hal Feng @ 2026-06-16  3:10 UTC (permalink / raw)
  To: Wentao Liang, kernel, mturquette, sboyd
  Cc: bmasney, linux-clk, linux-kernel, stable

> On 26.06.24 14:43, Wentao Liang wrote:
> 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.
> 
> Cc: stable@vger.kernel.org
> Fixes: 81279f5d0812 ("clk: starfive: Add StarFive JH7110 Image-Signal-Process
> clock driver")
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
>  drivers/clk/starfive/clk-starfive-jh7110-isp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/starfive/clk-starfive-jh7110-isp.c
> b/drivers/clk/starfive/clk-starfive-jh7110-isp.c
> index f3fa069db193..c02c8b29a123 100644
> --- a/drivers/clk/starfive/clk-starfive-jh7110-isp.c
> +++ b/drivers/clk/starfive/clk-starfive-jh7110-isp.c
> @@ -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.

Reviewed-by: Hal Feng <hal.feng@starfivetech.com>

Best regards,
Hal

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-16  3:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-04  6:43 [PATCH] clk: starfive: jh7110-isp: fix refcount leak in jh7110_ispcrg_probe() Wentao Liang
2026-06-16  3:10 ` Hal Feng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®