Skip to content

Commit

Permalink
leds: tca6507: Fix error handling of using fwnode_property_read_string
Browse files Browse the repository at this point in the history
[ Upstream commit c1087c2 ]

Commit 96f5241 ("leds: tca6507: use fwnode API instead of OF")

changed to fwnode API but did not take into account that a missing property
"linux,default-trigger" now seems to return an error and as a side effect
sets value to -1. This seems to be different from of_get_property() which
always returned NULL in any case of error.

Neglecting this side-effect leads to

[   11.201965] Unable to handle kernel paging request at virtual address ffffffff when read

in the strcmp() of led_trigger_set_default() if there is no led-trigger
defined in the DTS.

I don't know if this was recently introduced somewhere in the fwnode lib
or if the effect was missed in initial testing. Anyways it seems to be a
bug to ignore the error return value of an optional value here in the
driver.

Fixes: 96f5241 ("leds: tca6507: use fwnode API instead of OF")
Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Reviewed-by: Marek Behún <kabel@kernel.org>
Signed-off-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/cbae7617db83113de726fcc423a805ebaa1bfca6.1680433978.git.hns@goldelico.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
goldelico authored and gregkh committed May 11, 2023
1 parent caa413a commit 671b52c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/leds/leds-tca6507.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,9 @@ tca6507_led_dt_init(struct device *dev)
if (fwnode_property_read_string(child, "label", &led.name))
led.name = fwnode_get_name(child);

fwnode_property_read_string(child, "linux,default-trigger",
&led.default_trigger);
if (fwnode_property_read_string(child, "linux,default-trigger",
&led.default_trigger))
led.default_trigger = NULL;

led.flags = 0;
if (fwnode_device_is_compatible(child, "gpio"))
Expand Down

0 comments on commit 671b52c

Please sign in to comment.