]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
watchdog: starfive: Fix resource leak in probe error path
authorHaotian Zhang <vulab@iscas.ac.cn>
Wed, 5 Nov 2025 08:42:20 +0000 (16:42 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Dec 2025 13:03:02 +0000 (14:03 +0100)
commit4d9bebb2e9b6ddcca359e8701e09ae8f4cfdf9ae
tree02cf8dc5857d465609918f969e6a688e869fbf2c
parente2b25922e5664ce2406b7ec0aa3a89c8406d1b4b
watchdog: starfive: Fix resource leak in probe error path

[ Upstream commit 5bcc5786a0cfa9249ccbe539833040a6285d0de3 ]

If pm_runtime_put_sync() fails after watchdog_register_device()
succeeds, the probe function jumps to err_exit without
unregistering the watchdog device. This leaves the watchdog
registered in the subsystem while the driver fails to load,
resulting in a resource leak.

Add a new error label err_unregister_wdt to properly unregister
the watchdog device.

Fixes: 8bc22a2f1bf0 ("watchdog: starfive: Check pm_runtime_enabled() before decrementing usage counter")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
Reviewed-by: Wim Van Sebroeck <wim@linux-watchdog.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/watchdog/starfive-wdt.c