watchdog: starfive: Fix resource leak in probe error path
Subsystems (2)
PATCH 1/1 watchdog: starfive: Fix resource leak in probe error path
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.
--- drivers/watchdog/starfive-wdt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/watchdog/starfive-wdt.c +3 -1
@@ -500,12 +500,14 @@ static int starfive_wdt_probe(struct platform_device *pdev)if (pm_runtime_enabled (&pdev->dev)) { ret =pm_runtime_put_sync (&pdev->dev);if (ret) - goto err_exit; + goto err_unregister_wdt; } }return 0 ; +err_unregister_wdt: +watchdog_unregister_device (&wdt->wdd); err_exit:starfive_wdt_disable_clock (wdt);pm_runtime_disable (&pdev->dev);
Signature · 1 line
2.50.1.windows.1
Quoted 2 lines
If
pm_runtime_put_sync()fails afterwatchdog_register_device()succeeds, the probe function jumps toerr_exitwithout
…
Would an other word wrapping be a bit nicer for such a change description?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.18-rc4#n658
Regards,
Markus