Skip to content

Commit 73b03b2

Browse files
javiercarrascocruzlag-linaro
authored andcommitted
leds: flash: mt6360: Fix device_for_each_child_node() refcounting in error paths
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: 679f865 ("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>
1 parent da0806e commit 73b03b2

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/leds/flash/leds-mt6360.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,6 @@ static void mt6360_v4l2_flash_release(struct mt6360_priv *priv)
784784
static int mt6360_led_probe(struct platform_device *pdev)
785785
{
786786
struct mt6360_priv *priv;
787-
struct fwnode_handle *child;
788787
size_t count;
789788
int i = 0, ret;
790789

@@ -811,7 +810,7 @@ static int mt6360_led_probe(struct platform_device *pdev)
811810
return -ENODEV;
812811
}
813812

814-
device_for_each_child_node(&pdev->dev, child) {
813+
device_for_each_child_node_scoped(&pdev->dev, child) {
815814
struct mt6360_led *led = priv->leds + i;
816815
struct led_init_data init_data = { .fwnode = child, };
817816
u32 reg, led_color;

0 commit comments

Comments
 (0)