public inbox for linux-watchdog@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] watchdog: starfive-wdt: Fix PM reference leak in probe error path
@ 2026-01-11 17:29 Kery Qi
  2026-01-12 18:31 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Kery Qi @ 2026-01-11 17:29 UTC (permalink / raw)
  To: wim; +Cc: linux, linux-watchdog, Kery Qi

The PM reference count is not expected to be incremented on return in
functions starfive_wdt_probe.

However, pm_runtime_get_sync will increment pm usage counter
even failed. Forgetting to putting operation will result in a
reference leak here.

Replace it with pm_runtime_resume_and_get to keep usage
counter balanced.

Fixes: db728ea9c7be ("drivers: watchdog: Add StarFive Watchdog driver")
Signed-off-by: Kery Qi <qikeyu2017@gmail.com>
---
 drivers/watchdog/starfive-wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/starfive-wdt.c b/drivers/watchdog/starfive-wdt.c
index ed71d3960a0f..af55adc4a3c6 100644
--- a/drivers/watchdog/starfive-wdt.c
+++ b/drivers/watchdog/starfive-wdt.c
@@ -446,7 +446,7 @@ static int starfive_wdt_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, wdt);
 	pm_runtime_enable(&pdev->dev);
 	if (pm_runtime_enabled(&pdev->dev)) {
-		ret = pm_runtime_get_sync(&pdev->dev);
+		ret = pm_runtime_resume_and_get(&pdev->dev);
 		if (ret < 0)
 			return ret;
 	} else {
-- 
2.34.1


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

* Re: [PATCH] watchdog: starfive-wdt: Fix PM reference leak in probe error path
  2026-01-11 17:29 [PATCH] watchdog: starfive-wdt: Fix PM reference leak in probe error path Kery Qi
@ 2026-01-12 18:31 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2026-01-12 18:31 UTC (permalink / raw)
  To: Kery Qi, wim; +Cc: linux-watchdog

On 1/11/26 09:29, Kery Qi wrote:
> The PM reference count is not expected to be incremented on return in
> functions starfive_wdt_probe.
> 
> However, pm_runtime_get_sync will increment pm usage counter
> even failed. Forgetting to putting operation will result in a
> reference leak here.
> 
> Replace it with pm_runtime_resume_and_get to keep usage
> counter balanced.
> 
> Fixes: db728ea9c7be ("drivers: watchdog: Add StarFive Watchdog driver")
> Signed-off-by: Kery Qi <qikeyu2017@gmail.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   drivers/watchdog/starfive-wdt.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/watchdog/starfive-wdt.c b/drivers/watchdog/starfive-wdt.c
> index ed71d3960a0f..af55adc4a3c6 100644
> --- a/drivers/watchdog/starfive-wdt.c
> +++ b/drivers/watchdog/starfive-wdt.c
> @@ -446,7 +446,7 @@ static int starfive_wdt_probe(struct platform_device *pdev)
>   	platform_set_drvdata(pdev, wdt);
>   	pm_runtime_enable(&pdev->dev);
>   	if (pm_runtime_enabled(&pdev->dev)) {
> -		ret = pm_runtime_get_sync(&pdev->dev);
> +		ret = pm_runtime_resume_and_get(&pdev->dev);
>   		if (ret < 0)
>   			return ret;
>   	} else {


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

end of thread, other threads:[~2026-01-12 18:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-11 17:29 [PATCH] watchdog: starfive-wdt: Fix PM reference leak in probe error path Kery Qi
2026-01-12 18:31 ` Guenter Roeck

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