mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
net: dsa: hellcreek: fix missing error handling in LED registration
[ Upstream commite6751b0b19] 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:7d9ee2e8ff("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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
cbf2cbdb07
commit
470a2416b6
@@ -376,8 +376,18 @@ static int hellcreek_led_setup(struct hellcreek *hellcreek)
|
|||||||
hellcreek_set_brightness(hellcreek, STATUS_OUT_IS_GM, 1);
|
hellcreek_set_brightness(hellcreek, STATUS_OUT_IS_GM, 1);
|
||||||
|
|
||||||
/* Register both leds */
|
/* Register both leds */
|
||||||
led_classdev_register(hellcreek->dev, &hellcreek->led_sync_good);
|
ret = led_classdev_register(hellcreek->dev, &hellcreek->led_sync_good);
|
||||||
led_classdev_register(hellcreek->dev, &hellcreek->led_is_gm);
|
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;
|
ret = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user