Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

leds: mt6360: Fix memory leak in mt6360_init_isnk_properties()

The fwnode_for_each_child_node() loop requires manual intervention to
decrement the child refcount in case of an early return.

Add the missing calls to fwnode_handle_put(child) to avoid memory leaks
in the error paths.

Cc: stable@vger.kernel.org
Fixes: 679f8652064b ("leds: Add mt6360 driver")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Link: https://lore.kernel.org/r/20240611-leds-mt6360-memleak-v1-1-93642eb5011e@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Javier Carrasco and committed by
Lee Jones
e41d574b 8d89afc6

+4 -1
+4 -1
drivers/leds/flash/leds-mt6360.c
··· 643 643 644 644 ret = fwnode_property_read_u32(child, "reg", &reg); 645 645 if (ret || reg > MT6360_LED_ISNK3 || 646 - priv->leds_active & BIT(reg)) 646 + priv->leds_active & BIT(reg)) { 647 + fwnode_handle_put(child); 647 648 return -EINVAL; 649 + } 648 650 649 651 ret = fwnode_property_read_u32(child, "color", &color); 650 652 if (ret) { 651 653 dev_err(priv->dev, 652 654 "led %d, no color specified\n", 653 655 led->led_no); 656 + fwnode_handle_put(child); 654 657 return ret; 655 658 } 656 659