Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

leds: lp50xx: Put fwnode in error case during ->probe()

fwnode_for_each_child_node() bumps a reference counting of a returned variable.
We have to balance it whenever we return to the caller.

OTOH, the successful iteration will drop reference count under the hood, no need
to do it twice.

Fixes: 242b81170fb8 ("leds: lp50xx: Add the LP50XX family of the RGB LED driver")
Cc: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Pavel Machek <pavel@ucw.cz>

authored by

Andy Shevchenko and committed by
Pavel Machek
f1e1d532 807553f8

+1 -1
+1 -1
drivers/leds/leds-lp50xx.c
··· 490 490 ret = fwnode_property_read_u32(led_node, "color", 491 491 &color_id); 492 492 if (ret) { 493 + fwnode_handle_put(led_node); 493 494 dev_err(priv->dev, "Cannot read color\n"); 494 495 goto child_out; 495 496 } ··· 513 512 goto child_out; 514 513 } 515 514 i++; 516 - fwnode_handle_put(child); 517 515 } 518 516 519 517 return 0;