* [PATCH] leds: mt6360: Fix error path in device_for_each_child_node()
@ 2024-10-23 12:06 Zhang Zekun
2024-10-23 15:51 ` Matthias Brugger
2024-10-31 16:22 ` Lee Jones
0 siblings, 2 replies; 3+ messages in thread
From: Zhang Zekun @ 2024-10-23 12:06 UTC (permalink / raw)
To: pavel, lee, matthias.bgg, linux-leds; +Cc: chenjun102, zhangzekun11
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(-)
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;
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] leds: mt6360: Fix error path in device_for_each_child_node()
2024-10-23 12:06 [PATCH] leds: mt6360: Fix error path in device_for_each_child_node() Zhang Zekun
@ 2024-10-23 15:51 ` Matthias Brugger
2024-10-31 16:22 ` Lee Jones
1 sibling, 0 replies; 3+ messages in thread
From: Matthias Brugger @ 2024-10-23 15:51 UTC (permalink / raw)
To: Zhang Zekun, pavel, lee, linux-leds; +Cc: chenjun102
On 23/10/2024 14:06, 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>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
> ---
> drivers/leds/flash/leds-mt6360.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> 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;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] leds: mt6360: Fix error path in device_for_each_child_node()
2024-10-23 12:06 [PATCH] leds: mt6360: Fix error path in device_for_each_child_node() Zhang Zekun
2024-10-23 15:51 ` Matthias Brugger
@ 2024-10-31 16:22 ` Lee Jones
1 sibling, 0 replies; 3+ messages in thread
From: Lee Jones @ 2024-10-31 16:22 UTC (permalink / raw)
To: Zhang Zekun; +Cc: pavel, matthias.bgg, linux-leds, chenjun102
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
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-31 16:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-23 12:06 [PATCH] leds: mt6360: Fix error path in device_for_each_child_node() Zhang Zekun
2024-10-23 15:51 ` Matthias Brugger
2024-10-31 16:22 ` Lee Jones
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.