Skip to contentSkip to conversation

net: dsa: hellcreek: fix missing error handling in LED registration

PATCH Applied Pavel Zhigulin 4 participants 4 messages Nov 13, 2025 – Nov 15, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

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.

Fixes 7d9ee2e8ff15 ("net: dsa: hellcreek: Add PTP status LEDs")
---
 drivers/net/dsa/hirschmann/hellcreek_ptp.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/net/dsa/hirschmann/hellcreek_ptp.c +12 -2
index bfe21f9f7dcd..cb23bea9c21b 100644
@@ -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

maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Pavel Zhigulin

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?

Quoted 2 lines
Fixes 7d9ee2e8ff15 ("net: dsa: hellcreek: Add PTP status LEDs")

Andrew

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Pavel Zhigulin
Quoted 7 lines · Pavel Zhigulin

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.

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")
#3 lore raw
In reply to Pavel Zhigulin
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_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!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html