linux/drivers/leds/flash
Javier Carrasco 28a01c6b3f leds: flash: mt6360: Fix device_for_each_child_node() refcounting in error paths
[ Upstream commit 73b03b2773 ]

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: stable@vger.kernel.org
Fixes: 679f865206 ("leds: Add mt6360 driver")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_device_for_each_child_node_scoped-v1-1-95c0614b38c8@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2024-12-14 19:54:29 +01:00
..
Kconfig leds: Add mt6360 driver 2022-01-12 19:42:42 +01:00
leds-aat1290.c leds: aat1290: Move driver to flash subdirectory 2021-07-12 10:30:04 +02:00
leds-as3645a.c i2c: Make remove callback return void 2022-08-16 12:46:26 +02:00
leds-ktd2692.c leds: ktd2692: Make aux-gpios optional 2022-05-07 23:12:19 +02:00
leds-lm3601x.c i2c: Make remove callback return void 2022-08-16 12:46:26 +02:00
leds-max77693.c leds: max77693: Move driver to flash subdirectory 2021-07-12 10:30:05 +02:00
leds-mt6360.c leds: flash: mt6360: Fix device_for_each_child_node() refcounting in error paths 2024-12-14 19:54:29 +01:00
leds-rt4505.c i2c: Make remove callback return void 2022-08-16 12:46:26 +02:00
leds-rt8515.c leds: rt8515: Put fwnode in any case during ->probe() 2021-08-03 23:49:37 +02:00
leds-sgm3140.c leds: sgm3140: Add missing timer cleanup and flash gpio control 2024-03-26 18:20:52 -04:00
Makefile leds: Add mt6360 driver 2022-01-12 19:42:42 +01:00