Message ID | 20241023120628.15944-1-zhangzekun11@huawei.com |
---|---|
State | New |
Headers | show |
Series | leds: mt6360: Fix error path in device_for_each_child_node() | expand |
On Wed, 23 Oct 2024, Zhang Zekun wrote: > When break out from device_for_each_child_node(), the child node > is refcount added, and requires calls to fwnode_handle_put(). > Use scoped fwnode_handle_put() to put child node automatically in > error path. > > Fixes: 679f8652064b ("leds: Add mt6360 driver") > Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> > --- > drivers/leds/flash/leds-mt6360.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) You were beaten to it I'm afraid: https://lore.kernel.org/r/20240927-leds_device_for_each_child_node_scoped-v1-1-95c0614b38c8@gmail.com
diff --git a/drivers/leds/flash/leds-mt6360.c b/drivers/leds/flash/leds-mt6360.c index 4c74f1cf01f0..676236c19ec4 100644 --- a/drivers/leds/flash/leds-mt6360.c +++ b/drivers/leds/flash/leds-mt6360.c @@ -784,7 +784,6 @@ static void mt6360_v4l2_flash_release(struct mt6360_priv *priv) static int mt6360_led_probe(struct platform_device *pdev) { struct mt6360_priv *priv; - struct fwnode_handle *child; size_t count; int i = 0, ret; @@ -811,7 +810,7 @@ static int mt6360_led_probe(struct platform_device *pdev) return -ENODEV; } - device_for_each_child_node(&pdev->dev, child) { + device_for_each_child_node_scoped(&pdev->dev, child) { struct mt6360_led *led = priv->leds + i; struct led_init_data init_data = { .fwnode = child, }; u32 reg, led_color;
When break out from device_for_each_child_node(), the child node is refcount added, and requires calls to fwnode_handle_put(). Use scoped fwnode_handle_put() to put child node automatically in error path. Fixes: 679f8652064b ("leds: Add mt6360 driver") Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> --- drivers/leds/flash/leds-mt6360.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)