Commit b337cc3c authored by Javier Carrasco's avatar Javier Carrasco Committed by Lee Jones

backlight: lm3509_bl: Fix early returns in for_each_child_of_node()

The for_each_child_of_node() macro automatically decrements the child
refcount at the end of every iteration. On early exits, of_node_put()
must be used to manually decrement the refcount and avoid memory leaks.

The scoped version of the macro accounts for such early breaks, fixing
the early exits without the need for explicit calls to of_node_put().
Reported-by: default avatarkernel test robot <lkp@intel.com>
Reported-by: default avatarJulia Lawall <julia.lawall@inria.fr>
Closes: https://lore.kernel.org/r/202406172314.2vVgelaS-lkp@intel.com/
Fixes: b72755f5 ("backlight: Add new lm3509 backlight driver")
Signed-off-by: default avatarJavier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240624-lm3509_bl_scoped-v1-1-ceba9df38f23@gmail.comSigned-off-by: default avatarLee Jones <lee@kernel.org>
parent bfd35877
......@@ -157,10 +157,9 @@ static int lm3509_parse_led_sources(struct device_node *node,
static int lm3509_parse_dt_node(struct device *dev,
struct lm3509_bl_led_data *led_data)
{
struct device_node *child;
int seen_led_sources = 0;
for_each_child_of_node(dev->of_node, child) {
for_each_child_of_node_scoped(dev->of_node, child) {
struct lm3509_bl_led_data *ld;
int ret;
u32 reg;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment