[v2,12/13] leds: rt8515: Put fwnode in any case during ->probe()

Message ID 20210529111935.3849707-12-andy.shevchenko@gmail.com
State New
Headers show
Series
  • Untitled series #131922
Related show

Commit Message

Andy Shevchenko May 29, 2021, 11:19 a.m.
fwnode_get_next_available_child_node() bumps a reference counting of
a returned variable. We have to balance it whenever we return to
the caller.

Fixes: e1c6edcbea13 ("leds: rt8515: Add Richtek RT8515 LED driver")
Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
v2: no changes
 drivers/leds/flash/leds-rt8515.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Linus Walleij June 1, 2021, 10:06 a.m. | #1
On Sat, May 29, 2021 at 1:19 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:

> fwnode_get_next_available_child_node() bumps a reference counting of

> a returned variable. We have to balance it whenever we return to

> the caller.

>

> Fixes: e1c6edcbea13 ("leds: rt8515: Add Richtek RT8515 LED driver")

> Cc: Linus Walleij <linus.walleij@linaro.org>

> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>


Reviewed-by: Linus Walleij <linus.walleij@linaro.org>


Yours,
Linus Walleij
andy@surfacebook.localdomain June 5, 2021, 9:46 a.m. | #2
Tue, Jun 01, 2021 at 12:06:05PM +0200, Linus Walleij kirjoitti:
> On Sat, May 29, 2021 at 1:19 PM Andy Shevchenko

> <andy.shevchenko@gmail.com> wrote:

> 

> > fwnode_get_next_available_child_node() bumps a reference counting of

> > a returned variable. We have to balance it whenever we return to

> > the caller.

> >

> > Fixes: e1c6edcbea13 ("leds: rt8515: Add Richtek RT8515 LED driver")

> > Cc: Linus Walleij <linus.walleij@linaro.org>

> > Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> 

> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>


Thanks!

Pavel, can you, please, review this batch? I think I addressed most of your
comments if not all.

-- 
With Best Regards,
Andy Shevchenko
Pavel Machek Aug. 3, 2021, 9:50 p.m. | #3
On Sat 2021-06-05 12:46:11, andy@surfacebook.localdomain wrote:
> Tue, Jun 01, 2021 at 12:06:05PM +0200, Linus Walleij kirjoitti:

> > On Sat, May 29, 2021 at 1:19 PM Andy Shevchenko

> > <andy.shevchenko@gmail.com> wrote:

> > 

> > > fwnode_get_next_available_child_node() bumps a reference counting of

> > > a returned variable. We have to balance it whenever we return to

> > > the caller.

> > >

> > > Fixes: e1c6edcbea13 ("leds: rt8515: Add Richtek RT8515 LED driver")

> > > Cc: Linus Walleij <linus.walleij@linaro.org>

> > > Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> > 

> > Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

> 

> Thanks!

> 

> Pavel, can you, please, review this batch? I think I addressed most of your

> comments if not all.


10-12 applied, thanks.
									Pavel
-- 
http://www.livejournal.com/~pavelmachek
Pavel Machek Aug. 3, 2021, 9:51 p.m. | #4
On Sat 2021-06-05 12:46:11, andy@surfacebook.localdomain wrote:
> Tue, Jun 01, 2021 at 12:06:05PM +0200, Linus Walleij kirjoitti:

> > On Sat, May 29, 2021 at 1:19 PM Andy Shevchenko

> > <andy.shevchenko@gmail.com> wrote:

> > 

> > > fwnode_get_next_available_child_node() bumps a reference counting of

> > > a returned variable. We have to balance it whenever we return to

> > > the caller.

> > >

> > > Fixes: e1c6edcbea13 ("leds: rt8515: Add Richtek RT8515 LED driver")

> > > Cc: Linus Walleij <linus.walleij@linaro.org>

> > > Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> > 

> > Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

> 

> Thanks!

> 

> Pavel, can you, please, review this batch? I think I addressed most of your

> comments if not all.


Your original email is: From: andy@surfacebook.localdomain . I don't
believe that's right.

Best regards,
								Pavel

-- 
http://www.livejournal.com/~pavelmachek

Patch

diff --git a/drivers/leds/flash/leds-rt8515.c b/drivers/leds/flash/leds-rt8515.c
index 590bfa180d10..44904fdee3cc 100644
--- a/drivers/leds/flash/leds-rt8515.c
+++ b/drivers/leds/flash/leds-rt8515.c
@@ -343,8 +343,9 @@  static int rt8515_probe(struct platform_device *pdev)
 
 	ret = devm_led_classdev_flash_register_ext(dev, fled, &init_data);
 	if (ret) {
-		dev_err(dev, "can't register LED %s\n", led->name);
+		fwnode_handle_put(child);
 		mutex_destroy(&rt->lock);
+		dev_err(dev, "can't register LED %s\n", led->name);
 		return ret;
 	}
 
@@ -362,6 +363,7 @@  static int rt8515_probe(struct platform_device *pdev)
 		 */
 	}
 
+	fwnode_handle_put(child);
 	return 0;
 }