* [PATCH] leds: tca6507: fix error handling of using fwnode_property_read_string
@ 2023-04-02 11:12 H. Nikolaus Schaller
2023-04-03 9:09 ` Marek Behún
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: H. Nikolaus Schaller @ 2023-04-02 11:12 UTC (permalink / raw)
To: Marek Behún, Pavel Machek, Lee Jones
Cc: linux-leds, linux-kernel, letux-kernel, H. Nikolaus Schaller,
NeilBrown, Linus Walleij
Commit 96f524105b9c ("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: 96f524105b9c ("leds: tca6507: use fwnode API instead of OF")
Cc: Marek Behún <kabel@kernel.org>
Cc: NeilBrown <neilb@suse.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
---
drivers/leds/leds-tca6507.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c
index 07dd12686a696..634cabd5bb796 100644
--- a/drivers/leds/leds-tca6507.c
+++ b/drivers/leds/leds-tca6507.c
@@ -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"))
--
2.38.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] leds: tca6507: fix error handling of using fwnode_property_read_string
2023-04-02 11:12 [PATCH] leds: tca6507: fix error handling of using fwnode_property_read_string H. Nikolaus Schaller
@ 2023-04-03 9:09 ` Marek Behún
2023-04-03 15:23 ` Pavel Machek
2023-04-05 15:29 ` Lee Jones
2 siblings, 0 replies; 4+ messages in thread
From: Marek Behún @ 2023-04-03 9:09 UTC (permalink / raw)
To: H. Nikolaus Schaller
Cc: Pavel Machek, Lee Jones, linux-leds, linux-kernel, letux-kernel,
NeilBrown, Linus Walleij
On Sun, 2 Apr 2023 13:12:59 +0200
"H. Nikolaus Schaller" <hns@goldelico.com> wrote:
> Commit 96f524105b9c ("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: 96f524105b9c ("leds: tca6507: use fwnode API instead of OF")
> Cc: Marek Behún <kabel@kernel.org>
> Cc: NeilBrown <neilb@suse.de>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
> ---
> drivers/leds/leds-tca6507.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c
> index 07dd12686a696..634cabd5bb796 100644
> --- a/drivers/leds/leds-tca6507.c
> +++ b/drivers/leds/leds-tca6507.c
> @@ -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"))
Reviewed-by: Marek Behún <kabel@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] leds: tca6507: fix error handling of using fwnode_property_read_string
2023-04-02 11:12 [PATCH] leds: tca6507: fix error handling of using fwnode_property_read_string H. Nikolaus Schaller
2023-04-03 9:09 ` Marek Behún
@ 2023-04-03 15:23 ` Pavel Machek
2023-04-05 15:29 ` Lee Jones
2 siblings, 0 replies; 4+ messages in thread
From: Pavel Machek @ 2023-04-03 15:23 UTC (permalink / raw)
To: H. Nikolaus Schaller
Cc: Marek Behún, Lee Jones, linux-leds, linux-kernel,
letux-kernel, NeilBrown, Linus Walleij
[-- Attachment #1: Type: text/plain, Size: 1281 bytes --]
On Sun 2023-04-02 13:12:59, H. Nikolaus Schaller wrote:
> Commit 96f524105b9c ("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: 96f524105b9c ("leds: tca6507: use fwnode API instead of OF")
> Cc: Marek Behún <kabel@kernel.org>
> Cc: NeilBrown <neilb@suse.de>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
BR, Pavel
--
People of Russia, stop Putin before his war on Ukraine escalates.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] leds: tca6507: fix error handling of using fwnode_property_read_string
2023-04-02 11:12 [PATCH] leds: tca6507: fix error handling of using fwnode_property_read_string H. Nikolaus Schaller
2023-04-03 9:09 ` Marek Behún
2023-04-03 15:23 ` Pavel Machek
@ 2023-04-05 15:29 ` Lee Jones
2 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2023-04-05 15:29 UTC (permalink / raw)
To: H. Nikolaus Schaller
Cc: Marek Behún, Pavel Machek, linux-leds, linux-kernel,
letux-kernel, NeilBrown, Linus Walleij
On Sun, 02 Apr 2023, H. Nikolaus Schaller wrote:
> Commit 96f524105b9c ("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: 96f524105b9c ("leds: tca6507: use fwnode API instead of OF")
> Cc: Marek Behún <kabel@kernel.org>
> Cc: NeilBrown <neilb@suse.de>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
> ---
> drivers/leds/leds-tca6507.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
Applied, thanks
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-04-05 15:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-02 11:12 [PATCH] leds: tca6507: fix error handling of using fwnode_property_read_string H. Nikolaus Schaller
2023-04-03 9:09 ` Marek Behún
2023-04-03 15:23 ` Pavel Machek
2023-04-05 15:29 ` Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).