Skip to content

Commit 470a241

Browse files
Pavel Zhigulingregkh
authored andcommitted
net: dsa: hellcreek: fix missing error handling in LED registration
[ Upstream commit e6751b0 ] 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: 7d9ee2e ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent cbf2cbd commit 470a241

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

drivers/net/dsa/hirschmann/hellcreek_ptp.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,18 @@ static int hellcreek_led_setup(struct hellcreek *hellcreek)
376376
hellcreek_set_brightness(hellcreek, STATUS_OUT_IS_GM, 1);
377377

378378
/* 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+
}
381391

382392
ret = 0;
383393

0 commit comments

Comments
 (0)