On Thu, May 16, 2024 at 11:05 PM Linus Walleij <linus.walleij@xxxxxxxxxx> wrote: > On Thu, May 16, 2024 at 7:30 PM Luiz Angelo Daros de Luca > <luizluca@xxxxxxxxx> wrote: > > > On Sat, 27 Apr 2024 02:11:30 -0300 Luiz Angelo Daros de Luca wrote: > > > > +static int rtl8366rb_setup_leds(struct realtek_priv *priv) > > > > +{ > > > > + struct device_node *leds_np, *led_np; > > > > + struct dsa_switch *ds = &priv->ds; > > > > + struct dsa_port *dp; > > > > + int ret = 0; > > > > + > > > > + dsa_switch_for_each_port(dp, ds) { > > > > + if (!dp->dn) > > > > + continue; > > > > + > > > > + leds_np = of_get_child_by_name(dp->dn, "leds"); > > > > + if (!leds_np) { > > > > + dev_dbg(priv->dev, "No leds defined for port %d", > > > > + dp->index); > > > > + continue; > > > > + } > > > > + > > > > + for_each_child_of_node(leds_np, led_np) { > > > > + ret = rtl8366rb_setup_led(priv, dp, > > > > + of_fwnode_handle(led_np)); > > > > + if (ret) { > > > > + of_node_put(led_np); > > > > + break; > > > > + } > > > > + } > > > > + > > > > + of_node_put(leds_np); > > > > + if (ret) > > > > + return ret; > > > > + } > > > > + return 0; > > > > +} > > > > > > coccicheck generates this warning: > > > > > > drivers/net/dsa/realtek/rtl8366rb.c:1032:4-15: ERROR: probable double put. > > > > > > I think it's a false positive. > > > > Me too. I don't think it is a double put. The put for led_np is called > > in the increment code inside the for_each_child_of_node macro. With a > > break, we skip that part and we need to put it before leaving. I don't > > know coccicheck but maybe it got confused by the double for. > > Maybe I can use for_each_child_of_node_scoped() and > get the handling for free? The checkers should learn about > *_scoped now. > > (I'm still working on the patch, I'm just slow.) Referring to my Marvell LED patch, confusing it for this one, damn I need to get to sleep :D Luiz: try to use for_each_child_of_node_scoped()! Yours, Linus Walleij