Skip to content

Commit b337cc3

Browse files
javiercarrascocruzlag-linaro
authored andcommitted
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: kernel test robot <[email protected]> Reported-by: Julia Lawall <[email protected]> Closes: https://lore.kernel.org/r/[email protected]/ Fixes: b72755f ("backlight: Add new lm3509 backlight driver") Signed-off-by: Javier Carrasco <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent bfd3587 commit b337cc3

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/video/backlight/lm3509_bl.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,9 @@ static int lm3509_parse_led_sources(struct device_node *node,
157157
static int lm3509_parse_dt_node(struct device *dev,
158158
struct lm3509_bl_led_data *led_data)
159159
{
160-
struct device_node *child;
161160
int seen_led_sources = 0;
162161

163-
for_each_child_of_node(dev->of_node, child) {
162+
for_each_child_of_node_scoped(dev->of_node, child) {
164163
struct lm3509_bl_led_data *ld;
165164
int ret;
166165
u32 reg;

0 commit comments

Comments
 (0)