Commit 73b03b2
leds: flash: mt6360: Fix device_for_each_child_node() refcounting in error paths
The device_for_each_child_node() macro requires explicit calls to
fwnode_handle_put() upon early exits to avoid memory leaks, and in
this case the error paths are handled after jumping to
'out_flash_realease', which misses that required call to
to decrement the refcount of the child node.
A more elegant and robust solution is using the scoped variant of the
loop, which automatically handles such early exits.
Fix the child node refcounting in the error paths by using
device_for_each_child_node_scoped().
Cc: [email protected]
Fixes: 679f865 ("leds: Add mt6360 driver")
Signed-off-by: Javier Carrasco <[email protected]>
Link: https://lore.kernel.org/r/20240927-leds_device_for_each_child_node_scoped-v1-1-95c0614b38c8@gmail.com
Signed-off-by: Lee Jones <[email protected]>1 parent da0806e commit 73b03b2
1 file changed
+1
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
784 | 784 | | |
785 | 785 | | |
786 | 786 | | |
787 | | - | |
788 | 787 | | |
789 | 788 | | |
790 | 789 | | |
| |||
811 | 810 | | |
812 | 811 | | |
813 | 812 | | |
814 | | - | |
| 813 | + | |
815 | 814 | | |
816 | 815 | | |
817 | 816 | | |
| |||
0 commit comments