* [PATCH] leds: various: add missing put_device() call in netxbig_leds_get_of_pdata()
@ 2020-10-29 9:23 Yu Kuai
2020-10-29 17:49 ` Pavel Machek
0 siblings, 1 reply; 4+ messages in thread
From: Yu Kuai @ 2020-10-29 9:23 UTC (permalink / raw)
To: pavel, linus.walleij, j.anaszewski, simon.guinot
Cc: linux-leds, linux-kernel, yukuai3, yi.zhang
if of_find_device_by_node() succeed, netxbig_leds_get_of_pdata() doesn't
have a corresponding put_device(). Thus add jump target to fix the
exception handling for this function implementation.
Fixes: 2976b1798909 ("leds: netxbig: add device tree binding")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/leds/leds-netxbig.c | 35 ++++++++++++++++++++++++-----------
1 file changed, 24 insertions(+), 11 deletions(-)
diff --git a/drivers/leds/leds-netxbig.c b/drivers/leds/leds-netxbig.c
index e6fd47365b58..68fbf0b66fad 100644
--- a/drivers/leds/leds-netxbig.c
+++ b/drivers/leds/leds-netxbig.c
@@ -448,31 +448,39 @@ static int netxbig_leds_get_of_pdata(struct device *dev,
gpio_ext = devm_kzalloc(dev, sizeof(*gpio_ext), GFP_KERNEL);
if (!gpio_ext) {
of_node_put(gpio_ext_np);
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto put_device;
}
ret = netxbig_gpio_ext_get(dev, gpio_ext_dev, gpio_ext);
of_node_put(gpio_ext_np);
if (ret)
- return ret;
+ goto put_device;
pdata->gpio_ext = gpio_ext;
/* Timers (optional) */
ret = of_property_count_u32_elems(np, "timers");
if (ret > 0) {
- if (ret % 3)
- return -EINVAL;
+ if (ret % 3) {
+ ret = -EINVAL;
+ goto put_device;
+ }
+
num_timers = ret / 3;
timers = devm_kcalloc(dev, num_timers, sizeof(*timers),
GFP_KERNEL);
- if (!timers)
- return -ENOMEM;
+ if (!timers) {
+ ret = -ENOMEM;
+ goto put_device;
+ }
for (i = 0; i < num_timers; i++) {
u32 tmp;
of_property_read_u32_index(np, "timers", 3 * i,
&timers[i].mode);
- if (timers[i].mode >= NETXBIG_LED_MODE_NUM)
- return -EINVAL;
+ if (timers[i].mode >= NETXBIG_LED_MODE_NUM) {
+ ret = -EINVAL;
+ goto put_device;
+ }
of_property_read_u32_index(np, "timers",
3 * i + 1, &tmp);
timers[i].delay_on = tmp;
@@ -488,12 +496,15 @@ static int netxbig_leds_get_of_pdata(struct device *dev,
num_leds = of_get_available_child_count(np);
if (!num_leds) {
dev_err(dev, "No LED subnodes found in DT\n");
- return -ENODEV;
+ ret = -ENODEV;
+ goto put_device;
}
leds = devm_kcalloc(dev, num_leds, sizeof(*leds), GFP_KERNEL);
- if (!leds)
- return -ENOMEM;
+ if (!leds) {
+ ret = -ENOMEM;
+ goto put_device;
+ }
led = leds;
for_each_available_child_of_node(np, child) {
@@ -574,6 +585,8 @@ static int netxbig_leds_get_of_pdata(struct device *dev,
err_node_put:
of_node_put(child);
+put_device:
+ put_device(gpio_ext_dev);
return ret;
}
--
2.25.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] leds: various: add missing put_device() call in netxbig_leds_get_of_pdata()
2020-10-29 9:23 [PATCH] leds: various: add missing put_device() call in netxbig_leds_get_of_pdata() Yu Kuai
@ 2020-10-29 17:49 ` Pavel Machek
2020-10-29 18:25 ` Marek Behun
0 siblings, 1 reply; 4+ messages in thread
From: Pavel Machek @ 2020-10-29 17:49 UTC (permalink / raw)
To: Yu Kuai
Cc: linus.walleij, j.anaszewski, simon.guinot, linux-leds,
linux-kernel, yi.zhang
[-- Attachment #1: Type: text/plain, Size: 497 bytes --]
Hi!
> if of_find_device_by_node() succeed, netxbig_leds_get_of_pdata() doesn't
> have a corresponding put_device(). Thus add jump target to fix the
> exception handling for this function implementation.
>
> Fixes: 2976b1798909 ("leds: netxbig: add device tree binding")
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Thanks, applied.
But it seems to me similar handling is needed in "success" paths, no?
Best regards,
Pavel
--
http://www.livejournal.com/~pavelmachek
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] leds: various: add missing put_device() call in netxbig_leds_get_of_pdata()
2020-10-29 17:49 ` Pavel Machek
@ 2020-10-29 18:25 ` Marek Behun
2020-11-25 12:18 ` Pavel Machek
0 siblings, 1 reply; 4+ messages in thread
From: Marek Behun @ 2020-10-29 18:25 UTC (permalink / raw)
To: Pavel Machek
Cc: Yu Kuai, linus.walleij, j.anaszewski, simon.guinot, linux-leds,
linux-kernel, yi.zhang
On Thu, 29 Oct 2020 18:49:52 +0100
Pavel Machek <pavel@ucw.cz> wrote:
>
> Thanks, applied.
>
> But it seems to me similar handling is needed in "success" paths, no?
>
> Best regards,
> Pavel
Pavel, the subject of this commit is wrong.
It should begin with
leds: netxbig:
instead of
leds: various:
since the patch does not touch various drivers, only one: netxbig.
Marek
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] leds: various: add missing put_device() call in netxbig_leds_get_of_pdata()
2020-10-29 18:25 ` Marek Behun
@ 2020-11-25 12:18 ` Pavel Machek
0 siblings, 0 replies; 4+ messages in thread
From: Pavel Machek @ 2020-11-25 12:18 UTC (permalink / raw)
To: Marek Behun
Cc: Yu Kuai, linus.walleij, j.anaszewski, simon.guinot, linux-leds,
linux-kernel, yi.zhang
[-- Attachment #1: Type: text/plain, Size: 521 bytes --]
On Thu 2020-10-29 19:25:55, Marek Behun wrote:
> On Thu, 29 Oct 2020 18:49:52 +0100
> Pavel Machek <pavel@ucw.cz> wrote:
>
> >
> > Thanks, applied.
> >
> > But it seems to me similar handling is needed in "success" paths, no?
>
> Pavel, the subject of this commit is wrong.
> It should begin with
> leds: netxbig:
> instead of
> leds: various:
> since the patch does not touch various drivers, only one: netxbig.
Ok, thanks, fixed.
Pavel
--
http://www.livejournal.com/~pavelmachek
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-11-25 12:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-29 9:23 [PATCH] leds: various: add missing put_device() call in netxbig_leds_get_of_pdata() Yu Kuai
2020-10-29 17:49 ` Pavel Machek
2020-10-29 18:25 ` Marek Behun
2020-11-25 12:18 ` Pavel Machek
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.