* [PATCH net] net: dsa: hellcreek: fix missing error handling in LED registration
@ 2025-11-13 13:57 Pavel Zhigulin
2025-11-13 14:08 ` Andrew Lunn
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Pavel Zhigulin @ 2025-11-13 13:57 UTC (permalink / raw)
To: Kurt Kanzenbach
Cc: Pavel Zhigulin, Andrew Lunn, Vladimir Oltean, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Richard Cochran,
Florian Fainelli, netdev, linux-kernel, lvc-project
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.
Fixes: 7d9ee2e8ff15 ("net: dsa: hellcreek: Add PTP status LEDs")
Signed-off-by: Pavel Zhigulin <Pavel.Zhigulin@kaspersky.com>
---
drivers/net/dsa/hirschmann/hellcreek_ptp.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/net/dsa/hirschmann/hellcreek_ptp.c b/drivers/net/dsa/hirschmann/hellcreek_ptp.c
index bfe21f9f7dcd..cb23bea9c21b 100644
--- a/drivers/net/dsa/hirschmann/hellcreek_ptp.c
+++ b/drivers/net/dsa/hirschmann/hellcreek_ptp.c
@@ -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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: dsa: hellcreek: fix missing error handling in LED registration
2025-11-13 13:57 [PATCH net] net: dsa: hellcreek: fix missing error handling in LED registration Pavel Zhigulin
@ 2025-11-13 14:08 ` Andrew Lunn
2025-11-13 14:24 ` Kurt Kanzenbach
2025-11-15 2:01 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2025-11-13 14:08 UTC (permalink / raw)
To: Pavel Zhigulin
Cc: Kurt Kanzenbach, Vladimir Oltean, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Richard Cochran, Florian Fainelli,
netdev, linux-kernel, lvc-project
On Thu, Nov 13, 2025 at 04:57:44PM +0300, Pavel Zhigulin wrote:
> 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.
Does it say anything about leaking leds?
> Fixes: 7d9ee2e8ff15 ("net: dsa: hellcreek: Add PTP status LEDs")
> Signed-off-by: Pavel Zhigulin <Pavel.Zhigulin@kaspersky.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: dsa: hellcreek: fix missing error handling in LED registration
2025-11-13 13:57 [PATCH net] net: dsa: hellcreek: fix missing error handling in LED registration Pavel Zhigulin
2025-11-13 14:08 ` Andrew Lunn
@ 2025-11-13 14:24 ` Kurt Kanzenbach
2025-11-15 2:01 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Kurt Kanzenbach @ 2025-11-13 14:24 UTC (permalink / raw)
To: Pavel Zhigulin
Cc: Pavel Zhigulin, Andrew Lunn, Vladimir Oltean, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Richard Cochran,
Florian Fainelli, netdev, linux-kernel, lvc-project
[-- Attachment #1: Type: text/plain, Size: 626 bytes --]
On Thu Nov 13 2025, Pavel Zhigulin wrote:
> 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.
>
> Fixes: 7d9ee2e8ff15 ("net: dsa: hellcreek: Add PTP status LEDs")
> Signed-off-by: Pavel Zhigulin <Pavel.Zhigulin@kaspersky.com>
Acked-by: Kurt Kanzenbach <kurt@linutronix.de>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: dsa: hellcreek: fix missing error handling in LED registration
2025-11-13 13:57 [PATCH net] net: dsa: hellcreek: fix missing error handling in LED registration Pavel Zhigulin
2025-11-13 14:08 ` Andrew Lunn
2025-11-13 14:24 ` Kurt Kanzenbach
@ 2025-11-15 2:01 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-11-15 2:01 UTC (permalink / raw)
To: Pavel Zhigulin
Cc: kurt, andrew, olteanv, davem, edumazet, kuba, pabeni,
richardcochran, f.fainelli, netdev, linux-kernel, lvc-project
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 13 Nov 2025 16:57:44 +0300 you wrote:
> 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.
>
> [...]
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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-11-15 2:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-13 13:57 [PATCH net] net: dsa: hellcreek: fix missing error handling in LED registration Pavel Zhigulin
2025-11-13 14:08 ` Andrew Lunn
2025-11-13 14:24 ` Kurt Kanzenbach
2025-11-15 2:01 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox