diff options
author | Javier Carrasco <javier.carrasco.cruz@gmail.com> | 2024-07-21 18:19:03 +0300 |
---|---|---|
committer | Lee Jones <lee@kernel.org> | 2024-08-01 15:40:07 +0300 |
commit | ffbf1fcb421429916a861cfc25dfe0c6387dda75 (patch) | |
tree | 4c300f42e60553f06de5e555aa81e4ec77591f1c /drivers/leds/leds-pwm.c | |
parent | 29357f8a8c95df6e59ddb8f5ca8a77b523d0f0a4 (diff) | |
download | linux-ffbf1fcb421429916a861cfc25dfe0c6387dda75.tar.xz |
leds: bd2606mvv: Fix device child node usage in bd2606mvv_probe()
The current implementation accesses the `child` fwnode handle outside of
fwnode_for_each_available_child_node() without incrementing its
refcount. Add the missing call to `fwnode_handle_get(child)`.
The cleanup process where `child` is accessed is not right either
because a single call to `fwnode_handle_put()` is carried out in case of
an error, ignoring unasigned nodes at the point when the error happens.
Keep `child` inside of the first loop, and use the helper pointer that
receives references via `fwnode_handle_get()` to handle the child nodes
within the second loop.
Moreover, the iterated nodes are direct children of the device node,
and the `device_for_each_child_node()` macro accounts for child node
availability. By restricting `child` to live within that loop, the
scoped version of it can be used to simplify the error handling.
`fwnode_for_each_available_child_node()` is meant to access the child
nodes of an fwnode, and therefore not direct child nodes of the device
node.
Use `device_for_each_child_node_scoped()` to indicate device's direct
child nodes.
Fixes: 8325642d2757 ("leds: bd2606mvv: Driver for the Rohm 6 Channel i2c LED driver")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240721-device_for_each_child_node-available-v2-3-f33748fd8b2d@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
Diffstat (limited to 'drivers/leds/leds-pwm.c')
0 files changed, 0 insertions, 0 deletions