mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] watchdog: starfive-wdt: fix PM reference leak in probe error path
@ 2026-09-14 16:50 Ivy Lopez
  2026-09-15  3:20 ` [PATCH v2] " Ivy Lopez
  0 siblings, 1 reply; 4+ messages in thread
From: Ivy Lopez @ 2026-09-14 16:50 UTC (permalink / raw)
  To: xingyu.wu, ziv.xu, wim, linux; +Cc: linux-watchdog, linux-kernel, Ivy Lopez

pm_runtime_resume_and_get() increments the runtime PM usage counter
on success. If a later step in probe() fails (reset_init, clock rate
check, watchdog_start, or watchdog_register_device), control reaches
err_exit, which calls pm_runtime_disable() but never puts the
reference, leaking the PM usage count.

Add a pm_runtime_put_sync() call in err_exit, gated on
pm_runtime_enabled(), to balance the earlier get.

Fixes: db728ea9c7be ("drivers: watchdog: Add StarFive Watchdog driver")
Signed-off-by: Ivy Lopez <skunkolee@gmail.com>
---
 drivers/watchdog/starfive-wdt.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/watchdog/starfive-wdt.c b/drivers/watchdog/starfive-wdt.c
index af55adc4a3c6..f87f8d5a3dab 100644
--- a/drivers/watchdog/starfive-wdt.c
+++ b/drivers/watchdog/starfive-wdt.c
@@ -510,6 +510,8 @@ static int starfive_wdt_probe(struct platform_device *pdev)
 	watchdog_unregister_device(&wdt->wdd);
 err_exit:
 	starfive_wdt_disable_clock(wdt);
+	if (pm_runtime_enabled(&pdev->dev))
+		pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
 	return ret;
-- 
2.55.0


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

end of thread, other threads:[~2026-09-15  3:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-14 16:50 [PATCH] watchdog: starfive-wdt: fix PM reference leak in probe error path Ivy Lopez
2026-09-15  3:20 ` [PATCH v2] " Ivy Lopez
2026-09-15  3:46   ` Guenter Roeck
2026-09-15  3:49   ` Guenter Roeck

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®