* [PATCH] auxdisplay: ht16k33: Drop device node reference after registration failure in ht16k33_led_probe()
@ 2024-06-04 15:15 Markus Elfring
2024-06-04 16:33 ` Andy Shevchenko
0 siblings, 1 reply; 4+ messages in thread
From: Markus Elfring @ 2024-06-04 15:15 UTC (permalink / raw)
To: kernel-janitors, Andy Shevchenko, Geert Uytterhoeven,
Marek Behún, Miguel Ojeda, Robin van der Gracht
Cc: LKML
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Jun 2024 17:02:15 +0200
A failed call of the function “devm_led_classdev_register_ext”
can be reported.
Add a call of the function “fwnode_handle_put” for this error case.
Fixes: c223d9c636ed ("auxdisplay: ht16k33: Add LED support")
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/auxdisplay/ht16k33.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/auxdisplay/ht16k33.c b/drivers/auxdisplay/ht16k33.c
index ce987944662c..ef86537c9d83 100644
--- a/drivers/auxdisplay/ht16k33.c
+++ b/drivers/auxdisplay/ht16k33.c
@@ -483,8 +483,10 @@ static int ht16k33_led_probe(struct device *dev, struct led_classdev *led,
led->max_brightness = MAX_BRIGHTNESS;
err = devm_led_classdev_register_ext(dev, led, &init_data);
- if (err)
+ if (err) {
dev_err(dev, "Failed to register LED\n");
+ fwnode_handle_put(init_data.fwnode);
+ }
return err;
}
--
2.45.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] auxdisplay: ht16k33: Drop device node reference after registration failure in ht16k33_led_probe()
2024-06-04 15:15 [PATCH] auxdisplay: ht16k33: Drop device node reference after registration failure in ht16k33_led_probe() Markus Elfring
@ 2024-06-04 16:33 ` Andy Shevchenko
2024-06-04 18:15 ` Markus Elfring
0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2024-06-04 16:33 UTC (permalink / raw)
To: Markus Elfring
Cc: kernel-janitors, Geert Uytterhoeven, Marek Behún,
Miguel Ojeda, Robin van der Gracht, LKML
On Tue, Jun 04, 2024 at 05:15:37PM +0200, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 4 Jun 2024 17:02:15 +0200
>
> A failed call of the function “devm_led_classdev_register_ext”
> can be reported.
> Add a call of the function “fwnode_handle_put” for this error case.
Replace double quotes by parentheses, so the reference to the functions
will look like func().
...
> err = devm_led_classdev_register_ext(dev, led, &init_data);
> - if (err)
> + if (err) {
> dev_err(dev, "Failed to register LED\n");
> + fwnode_handle_put(init_data.fwnode);
> + }
There are two issues with this approach:
1) there is the same issue in ->remove(), isn't it?
2) it potentially might mess up the ordering if any other devm call happens
in beetween.
But, by design we don't use reference counting after we registered LED, hence
both error and successful paths need to have this, so add another
fwnode_handle_put() after this branch.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: auxdisplay: ht16k33: Drop device node reference after registration failure in ht16k33_led_probe()
2024-06-04 16:33 ` Andy Shevchenko
@ 2024-06-04 18:15 ` Markus Elfring
2024-06-04 19:30 ` Andy Shevchenko
0 siblings, 1 reply; 4+ messages in thread
From: Markus Elfring @ 2024-06-04 18:15 UTC (permalink / raw)
To: Andy Shevchenko, kernel-janitors
Cc: Geert Uytterhoeven, Marek Behún, Miguel Ojeda,
Robin van der Gracht, LKML
> But, by design we don't use reference counting after we registered LED,
> hence both error and successful paths need to have this,
Do you indicate really special data processing constraints here?
> so add another fwnode_handle_put() after this branch.
Will this suggestion trigger any further clarifications for the affected software?
Regards,
Markus
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: auxdisplay: ht16k33: Drop device node reference after registration failure in ht16k33_led_probe()
2024-06-04 18:15 ` Markus Elfring
@ 2024-06-04 19:30 ` Andy Shevchenko
0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2024-06-04 19:30 UTC (permalink / raw)
To: Markus Elfring
Cc: kernel-janitors, Geert Uytterhoeven, Marek Behún,
Miguel Ojeda, Robin van der Gracht, LKML
On Tue, Jun 04, 2024 at 08:15:35PM +0200, Markus Elfring wrote:
> > But, by design we don't use reference counting after we registered LED,
> > hence both error and successful paths need to have this,
>
> Do you indicate really special data processing constraints here?
Nothing special, either we hold reference for the entire life time of the
device or not. For LEDS the convention is not to hold.
> > so add another fwnode_handle_put() after this branch.
>
> Will this suggestion trigger any further clarifications for the affected software?
You need to put an fwnode handle in both paths: inside the if branch as you
have done (error path) and missing one is after that needs to be added.
Just address my comments and I believe everyone will be happy about it.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-06-04 19:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-04 15:15 [PATCH] auxdisplay: ht16k33: Drop device node reference after registration failure in ht16k33_led_probe() Markus Elfring
2024-06-04 16:33 ` Andy Shevchenko
2024-06-04 18:15 ` Markus Elfring
2024-06-04 19:30 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome