]> www.infradead.org Git - users/jedix/linux-maple.git/commit
leds: pca995x: Fix device child node usage in pca995x_probe()
authorJavier Carrasco <javier.carrasco.cruz@gmail.com>
Wed, 7 Aug 2024 13:37:03 +0000 (15:37 +0200)
committerLee Jones <lee@kernel.org>
Fri, 16 Aug 2024 16:01:19 +0000 (17:01 +0100)
commit82c5ada1f9d05902a4ccb926c7ce34e2fe699283
treeb28aab07c829fd014b2663d21fc17097a5078dce
parent616dbed65485c6e68325d00b6258a05369c14705
leds: pca995x: Fix device child node usage in pca995x_probe()

The current implementation accesses the `child` fwnode handle outside of
device_for_each_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. Keeping `child` inside the first node has also
the advantage that the scoped version of the loop can be used.

Fixes: ee4e80b2962e ("leds: pca995x: Add support for PCA995X chips")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240807-leds-pca995x-fix-fwnode-usage-v1-1-8057c84dc583@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/leds/leds-pca995x.c