Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

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>
Acked-by: Kurt Kanzenbach <kurt@linutronix.de>
Link: https://patch.msgid.link/20251113135745.92375-1-Pavel.Zhigulin@kaspersky.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Pavel Zhigulin and committed by
Jakub Kicinski
e6751b0b 407a0650

+12 -2
+12 -2
drivers/net/dsa/hirschmann/hellcreek_ptp.c
··· 376 376 hellcreek_set_brightness(hellcreek, STATUS_OUT_IS_GM, 1); 377 377 378 378 /* Register both leds */ 379 - led_classdev_register(hellcreek->dev, &hellcreek->led_sync_good); 380 - led_classdev_register(hellcreek->dev, &hellcreek->led_is_gm); 379 + ret = led_classdev_register(hellcreek->dev, &hellcreek->led_sync_good); 380 + if (ret) { 381 + dev_err(hellcreek->dev, "Failed to register sync_good LED\n"); 382 + goto out; 383 + } 384 + 385 + ret = led_classdev_register(hellcreek->dev, &hellcreek->led_is_gm); 386 + if (ret) { 387 + dev_err(hellcreek->dev, "Failed to register is_gm LED\n"); 388 + led_classdev_unregister(&hellcreek->led_sync_good); 389 + goto out; 390 + } 381 391 382 392 ret = 0; 383 393