leds: rgb: leds-ktd202x: Fix error code in ktd202x_setup_led_rgb()
Subsystems (2)
PATCH 1/1 leds: rgb: leds-ktd202x: Fix error code in ktd202x_setup_led_rgb()
Return -EINVAL if the "reg" value is invalid. This is unlikely to happen in real life because it comes from the firmware, whether from device tree or ACPI.
--- drivers/leds/rgb/leds-ktd202x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/leds/rgb/leds-ktd202x.c +1 -1
@@ -410,7 +410,7 @@ static int ktd202x_setup_led_rgb(struct ktd202x *chip, struct fwnode_handle *fwnif (ret !=0 || reg >= chip->num_leds) {dev_err (chip->dev,"invalid 'reg' of %pfw\n" , child);fwnode_handle_put (child); -return ret; +return ret ?: -EINVAL ; } ret =fwnode_property_read_u32 (child,"color" , &mono_color);
Signature · 1 line
2.51.0
Quoted 4 lines · Dan Carpenter
Return
-EINVALif the "reg" value is invalid. This is unlikely to happen in real life because it comes from the firmware, whether from device tree or ACPI.
...
drivers/leds/rgb/leds-ktd202x.c static int ktd202x_setup_led_rgb(struct ktd202x *chip, struct fwnode_handle *fwn · line 414
Quoted 6 lines
if (ret != 0 || reg >= chip->num_leds) { dev_err(chip->dev, "invalid 'reg' of %pfw\n", child); fwnode_handle_put(child);drivers/leds/rgb/leds-ktd202x.c +1
-1-return ret; +return ret ?: -EINVAL ; }
I think the better fix is to split the original conditional to two.
And make the message something like
"can't retrieve 'reg' property of %pfw\n'
for the case if (ret).
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 15 lines · Andy Shevchenko
Quoted 4 lines · Dan Carpenter
Return
-EINVALif the "reg" value is invalid. This is unlikely to happen in real life because it comes from the firmware, whether from device tree or ACPI....
drivers/leds/rgb/leds-ktd202x.c static int ktd202x_setup_led_rgb(struct ktd202x *chip, struct fwnode_handle *fwn · line 414
Quoted 6 lines
if (ret != 0 || reg >= chip->num_leds) { dev_err(chip->dev, "invalid 'reg' of %pfw\n", child); fwnode_handle_put(child);drivers/leds/rgb/leds-ktd202x.c +1
-1-return ret; +return ret ?: -EINVAL ; }
Quoted 6 lines
I think the better fix is to split the original conditional to two.
And make the message something like
"can't retrieve 'reg' property of %pfw\n'
for the case if (ret).
These are never going to show up for users, the messages are only for developers bringing up a board...
regards,
dan carpenter
Quoted 2 lines · Dan Carpenter
Quoted 1 line · Andy Shevchenko
On Tue, Dec 9, 2025 at 8:56 AM Dan Carpenter <[email protected]> wrote:
...
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
if (ret != 0 || reg >= chip->num_leds) { dev_err(chip->dev, "invalid 'reg' of %pfw\n", child); fwnode_handle_put(child);drivers/leds/rgb/leds-ktd202x.c +1
-1-return ret; +return ret ?: -EINVAL ; }
Quoted 8 lines
Quoted 5 lines
I think the better fix is to split the original conditional to two.
And make the message something like
"can't retrieve 'reg' property of %pfw\n'
for the case if (ret).These are never going to show up for users, the messages are only for developers bringing up a board...
Even better,
if (ret) {
fwnode_handle_put(...);
return ret;
}
if (reg >= ...) {
...
}Since it's a fix likely for a backporting, the separate change can move to the _scoped() for_each loop and drop those fwnode_handle_put() calls.
Signature · 2 lines
With Best Regards, Andy Shevchenko