Skip to content

Commit d225d43

Browse files
krzklag-linaro
authored andcommitted
leds: max77693: Add missing of_node_get for probe duration
At beginning of probe() function, the driver iterates over OF children and assigns found device node for later. The code uses for_each_available_child_of_node() which drops the references on children on each successful pass, thus the probe function operates later on the device node without holding the reference. Fix this by increasing the reference count for found child node and drop it at the end of the probe, because it is not needed further (the V4L init code takes its own references). Signed-off-by: Krzysztof Kozlowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 700b6c9 commit d225d43

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/leds/flash/leds-max77693.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ static int max77693_led_parse_dt(struct max77693_led_device *led,
649649
return -EINVAL;
650650
}
651651

652-
sub_nodes[fled_id] = child_node;
652+
sub_nodes[fled_id] = of_node_get(child_node);
653653
sub_leds[fled_id].fled_id = fled_id;
654654

655655
cfg->label[fled_id] =
@@ -968,7 +968,7 @@ static int max77693_led_probe(struct platform_device *pdev)
968968

969969
ret = max77693_setup(led, &led_cfg);
970970
if (ret < 0)
971-
return ret;
971+
goto err_setup;
972972

973973
mutex_init(&led->lock);
974974

@@ -1000,6 +1000,8 @@ static int max77693_led_probe(struct platform_device *pdev)
10001000
else
10011001
goto err_register_led1;
10021002
}
1003+
of_node_put(sub_nodes[i]);
1004+
sub_nodes[i] = NULL;
10031005
}
10041006

10051007
return 0;
@@ -1013,6 +1015,9 @@ static int max77693_led_probe(struct platform_device *pdev)
10131015
err_register_led1:
10141016
mutex_destroy(&led->lock);
10151017

1018+
err_setup:
1019+
for (i = FLED1; i <= FLED2; i++)
1020+
of_node_put(sub_nodes[i]);
10161021
return ret;
10171022
}
10181023

0 commit comments

Comments
 (0)