Skip to content

Commit

Permalink
leds: mt6360: Fix memory leak in mt6360_init_isnk_properties()
Browse files Browse the repository at this point in the history
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: [email protected]
Fixes: 679f865 ("leds: Add mt6360 driver")
Signed-off-by: Javier Carrasco <[email protected]>
Acked-by: Pavel Machek <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Lee Jones <[email protected]>
  • Loading branch information
javiercarrascocruz authored and lag-linaro committed Jun 26, 2024
1 parent 8d89afc commit e41d574
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/leds/flash/leds-mt6360.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,14 +643,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;
}

Expand Down

0 comments on commit e41d574

Please sign in to comment.