aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier Carrasco <[email protected]>2024-06-24 17:30:50 +0200
committerLee Jones <[email protected]>2024-06-26 16:49:59 +0100
commitb337cc3ce47549528fc3ee0b8c7ebd33348a3126 (patch)
tree828f328affb3a2bc78ab4134d3c9f0d42294974d
parentbfd3587760498227510acc1b18c4299c7922ffe3 (diff)
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: b72755f5b577 ("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]>
-rw-r--r--drivers/video/backlight/lm3509_bl.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/video/backlight/lm3509_bl.c b/drivers/video/backlight/lm3509_bl.c
index 11b8e1824e07..24e1a19ff72d 100644
--- a/drivers/video/backlight/lm3509_bl.c
+++ b/drivers/video/backlight/lm3509_bl.c
@@ -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;