leds: mt6360: Fix memory leak in mt6360_init_isnk_properties()

commit e41d574b35 upstream.

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: 679f865206 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Javier Carrasco 2024-06-11 00:40:26 +02:00 committed by Greg Kroah-Hartman
parent 655cc01889
commit 04a4668b08
1 changed files with 4 additions and 1 deletions

View File

@ -633,14 +633,17 @@ static int mt6360_init_isnk_properties(struct mt6360_led *led,
ret = fwnode_property_read_u32(child, "reg", &reg);
if (ret || reg > MT6360_LED_ISNK3 ||
priv->leds_active & BIT(reg))
priv->leds_active & BIT(reg)) {
fwnode_handle_put(child);
return -EINVAL;
}
ret = fwnode_property_read_u32(child, "color", &color);
if (ret) {
dev_err(priv->dev,
"led %d, no color specified\n",
led->led_no);
fwnode_handle_put(child);
return ret;
}