Skip to content

Commit 8bc22a2

Browse files
JiShengTeohWim Van Sebroeck
authored andcommitted
watchdog: starfive: Check pm_runtime_enabled() before decrementing usage counter
In the probe function, pm_runtime_put_sync() will fail on platform with runtime PM disabled. Check if runtime PM is enabled before calling pm_runtime_put_sync() to fix it. Fixes: db728ea ("drivers: watchdog: Add StarFive Watchdog driver") Signed-off-by: Xingyu Wu <xingyu.wu@starfivetech.com> Signed-off-by: Ley Foon Tan <leyfoon.tan@starfivetech.com> Signed-off-by: Ji Sheng Teoh <jisheng.teoh@starfivetech.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/20240119082722.1133024-1-jisheng.teoh@starfivetech.com Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
1 parent 975e4b2 commit 8bc22a2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/watchdog/starfive-wdt.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,13 @@ static int starfive_wdt_probe(struct platform_device *pdev)
494494
if (ret)
495495
goto err_exit;
496496

497-
if (!early_enable)
498-
pm_runtime_put_sync(&pdev->dev);
497+
if (!early_enable) {
498+
if (pm_runtime_enabled(&pdev->dev)) {
499+
ret = pm_runtime_put_sync(&pdev->dev);
500+
if (ret)
501+
goto err_exit;
502+
}
503+
}
499504

500505
return 0;
501506

0 commit comments

Comments
 (0)