]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
watchdog: starfive-wdt: Fix PM reference leak in probe error path
authorKery Qi <qikeyu2017@gmail.com>
Sun, 11 Jan 2026 17:29:15 +0000 (01:29 +0800)
committerWim Van Sebroeck <wim@linux-watchdog.org>
Sat, 17 Jan 2026 12:09:12 +0000 (13:09 +0100)
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>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
drivers/watchdog/starfive-wdt.c

index ed71d3960a0f2622b85d71a6dc7252b5b6e69105..af55adc4a3c69be57ee33bbd1991c020e2316aaa 100644 (file)
@@ -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 {