2020-09-26 00:52:48

by Tobias Jordan

[permalink] [raw]
Subject: [PATCH v2] leds: tlc591xx: fix leak of device node iterator

In one of the error paths of the for_each_child_of_node loop in
tlc591xx_probe, add missing call to of_node_put.

Fixes: 1ab4531ad132 ("leds: tlc591xx: simplify driver by using the
managed led API")

Signed-off-by: Tobias Jordan <[email protected]>
---
v2: rebased to Pavel's for-next branch

drivers/leds/leds-tlc591xx.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/leds-tlc591xx.c b/drivers/leds/leds-tlc591xx.c
index f24271337bd8..5b9dfdf743ec 100644
--- a/drivers/leds/leds-tlc591xx.c
+++ b/drivers/leds/leds-tlc591xx.c
@@ -205,10 +205,12 @@ tlc591xx_probe(struct i2c_client *client,
led->ldev.max_brightness = TLC591XX_MAX_BRIGHTNESS;
err = devm_led_classdev_register_ext(dev, &led->ldev,
&init_data);
- if (err < 0)
+ if (err < 0) {
+ of_node_put(child);
return dev_err_probe(dev, err,
"couldn't register LED %s\n",
led->ldev.name);
+ }
}
return 0;
}
--
2.20.1


2020-09-26 01:25:54

by Marek Behún

[permalink] [raw]
Subject: Re: [PATCH v2] leds: tlc591xx: fix leak of device node iterator

On Sat, 26 Sep 2020 02:51:17 +0200
Tobias Jordan <[email protected]> wrote:

> In one of the error paths of the for_each_child_of_node loop in
> tlc591xx_probe, add missing call to of_node_put.
>
> Fixes: 1ab4531ad132 ("leds: tlc591xx: simplify driver by using the
> managed led API")
>
> Signed-off-by: Tobias Jordan <[email protected]>
> ---
> v2: rebased to Pavel's for-next branch
>
> drivers/leds/leds-tlc591xx.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/leds/leds-tlc591xx.c b/drivers/leds/leds-tlc591xx.c
> index f24271337bd8..5b9dfdf743ec 100644
> --- a/drivers/leds/leds-tlc591xx.c
> +++ b/drivers/leds/leds-tlc591xx.c
> @@ -205,10 +205,12 @@ tlc591xx_probe(struct i2c_client *client,
> led->ldev.max_brightness = TLC591XX_MAX_BRIGHTNESS;
> err = devm_led_classdev_register_ext(dev, &led->ldev,
> &init_data);
> - if (err < 0)
> + if (err < 0) {
> + of_node_put(child);
> return dev_err_probe(dev, err,
> "couldn't register LED %s\n",
> led->ldev.name);
> + }
> }
> return 0;
> }

Reviewed-by: Marek Behún <[email protected]>

2020-09-30 17:14:00

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH v2] leds: tlc591xx: fix leak of device node iterator

Hi!

> > In one of the error paths of the for_each_child_of_node loop in
> > tlc591xx_probe, add missing call to of_node_put.
> >
> > Fixes: 1ab4531ad132 ("leds: tlc591xx: simplify driver by using the
> > managed led API")
> >
> > Signed-off-by: Tobias Jordan <[email protected]>
>
> Reviewed-by: Marek Beh?n <[email protected]>

Thanks, applied.

Marek: Thanks for review. If I can get you to trim parts not
interesting for the email, I'll be even happier.

:-).

Best regards,

Pavel

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (657.00 B)
signature.asc (201.00 B)
Download all attachments