net: dsa: hellcreek: fix missing error handling in LED registration
PATCH 1/1 net: dsa: hellcreek: fix missing error handling in LED registration
The LED setup routine registered both led_sync_good and led_is_gm devices without checking the return values of led_classdev_register(). If either registration failed, the function continued silently, leaving the driver in a partially-initialized state and leaking a registered LED classdev.
Add proper error handling
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/net/dsa/hirschmann/hellcreek_ptp.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/net/dsa/hirschmann/hellcreek_ptp.c +12 -2
@@ -376,8 +376,18 @@ static int hellcreek_led_setup(struct hellcreek *hellcreek)hellcreek_set_brightness (hellcreek,STATUS_OUT_IS_GM ,1 );/* Register both leds */ -led_classdev_register (hellcreek->dev, &hellcreek->led_sync_good); -led_classdev_register (hellcreek->dev, &hellcreek->led_is_gm); + ret =led_classdev_register (hellcreek->dev, &hellcreek->led_sync_good); +if (ret) { +dev_err (hellcreek->dev,"Failed to register sync_good LED\n" ); + goto out; + } + + ret =led_classdev_register (hellcreek->dev, &hellcreek->led_is_gm); +if (ret) { +dev_err (hellcreek->dev,"Failed to register is_gm LED\n" ); +led_classdev_unregister (&hellcreek->led_sync_good); + goto out; + } ret =0 ;
--
2.43.0
Quoted 10 lines · Pavel Zhigulin
The LED setup routine registered both
led_sync_goodandled_is_gmdevices without checking the return values ofled_classdev_register(). If either registration failed, the function continued silently, leaving the driver in a partially-initialized state and leaking a registered LED classdev.Add proper error handling
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Does it say anything about leaking leds?
Quoted 2 lines
Fixes 7d9ee2e8ff15 ("net: dsa: hellcreek: Add PTP status LEDs")Signed-off-by Pavel Zhigulin <[email protected]>
Andrew
Quoted 7 lines · Pavel Zhigulin
The LED setup routine registered both
led_sync_goodandled_is_gmdevices without checking the return values ofled_classdev_register(). If either registration failed, the function continued silently, leaving the driver in a partially-initialized state and leaking a registered LED classdev.
Quoted 6 lines
Add proper error handling
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes 7d9ee2e8ff15 ("net: dsa: hellcreek: Add PTP status LEDs")Signed-off-by Pavel Zhigulin <[email protected]>
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Thu, 13 Nov 2025 16:57:44 +0300 you wrote:
The LED setup routine registered both
led_sync_goodandled_is_gmdevices without checking the return values ofled_classdev_register(). If either registration failed, the function continued silently, leaving the driver in a partially-initialized state and leaking a registered LED classdev.[...]
Here is the summary with links:
- [net] net: dsa: hellcreek: fix missing error handling in LED registration
https://git.kernel.org/netdev/net/c/e6751b0b19a6
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html