Skip to content

Commit 19d1cc7

Browse files
javiercarrascocruzlag-linaro
authored andcommitted
leds: flash: mt6370: Switch to device_for_each_child_node_scoped()
Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for calls to fwnode_handle_put() in the error paths. This also prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). Signed-off-by: Javier Carrasco <[email protected]> Link: https://lore.kernel.org/r/20240927-leds_device_for_each_child_node_scoped-v1-2-95c0614b38c8@gmail.com Signed-off-by: Lee Jones <[email protected]>
1 parent 73b03b2 commit 19d1cc7

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

drivers/leds/flash/leds-mt6370-flash.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,6 @@ static int mt6370_led_probe(struct platform_device *pdev)
509509
{
510510
struct device *dev = &pdev->dev;
511511
struct mt6370_priv *priv;
512-
struct fwnode_handle *child;
513512
size_t count;
514513
int i = 0, ret;
515514

@@ -529,22 +528,18 @@ static int mt6370_led_probe(struct platform_device *pdev)
529528
if (!priv->regmap)
530529
return dev_err_probe(dev, -ENODEV, "Failed to get parent regmap\n");
531530

532-
device_for_each_child_node(dev, child) {
531+
device_for_each_child_node_scoped(dev, child) {
533532
struct mt6370_led *led = priv->leds + i;
534533

535534
led->priv = priv;
536535

537536
ret = mt6370_init_flash_properties(dev, led, child);
538-
if (ret) {
539-
fwnode_handle_put(child);
537+
if (ret)
540538
return ret;
541-
}
542539

543540
ret = mt6370_led_register(dev, led, child);
544-
if (ret) {
545-
fwnode_handle_put(child);
541+
if (ret)
546542
return ret;
547-
}
548543

549544
i++;
550545
}

0 commit comments

Comments
 (0)