Re: [PATCH v3] irqchip/gic-v3-its: Drop ITS node reference on its_of_probe() errors

From: Geert Uytterhoeven

Date: Tue Nov 17 2026 - 08:31:43 EST


Hi Yuho,

CC devicetree

On Thu, 12 Nov 2026 at 22:47, Yuho Choi <oss.patchbox@xxxxxxxxx> wrote:
> its_of_probe() walks the ITS nodes with of_find_matching_node(), which
> drops the reference on the previous node and returns the next one with
> its reference count raised. The loops are balanced when they run to the
> end, but the three error returns (a failed its_reset_one(), a failed
> its_node_init() and a failed its_probe_one()) leave with the current
> node still referenced.
>
> Declare the iterator in each loop with __free(device_node), so that the
> reference is dropped whichever way the loop is left.
>
> Fixes: c733ebb7cb67 ("irqchip/gic-v3-its: Reset each ITS's BASERn register before probe")
> Fixes: 9585a495ac93 ("irqchip/gic-v3-its: Split allocation from initialisation of its_node")
> Suggested-by: Marc Zyngier <maz@xxxxxxxxxx>
> Signed-off-by: Yuho Choi <oss.patchbox@xxxxxxxxx>
> Acked-by: Marc Zyngier <maz@xxxxxxxxxx>

Thanks for your patch, which is now commit aab02e49f0b54a08
("irqchip/gic-v3-its: Drop ITS node reference on its_of_probe()
errors") in irqchip/irq/drivers.

> --- a/drivers/irqchip/irq-gic-v3-its.c
> +++ b/drivers/irqchip/irq-gic-v3-its.c
> @@ -5572,7 +5572,6 @@ static void its_node_destroy(struct its_node *its)
>
> static int __init its_of_probe(struct device_node *node)
> {
> - struct device_node *np;
> struct resource res;
> int err;
>
> @@ -5582,7 +5581,7 @@ static int __init its_of_probe(struct device_node *node)
> * reset, don't even try to go any further, as this could
> * result in something even worse.
> */
> - for (np = of_find_matching_node(node, its_device_id); np;
> + for (struct device_node *np __free(device_node) = of_find_matching_node(node, its_device_id); np;
> np = of_find_matching_node(np, its_device_id)) {

So the old code was just an open-coded copy of the existing
for_each_matching_node() helper.
The new code is the open-coded original for a future
for_each_matching_node_scoped() helper?

> if (!of_device_is_available(np) ||
> !of_property_read_bool(np, "msi-controller") ||
> @@ -5594,7 +5593,7 @@ static int __init its_of_probe(struct device_node *node)
> return err;
> }
>
> - for (np = of_find_matching_node(node, its_device_id); np;
> + for (struct device_node *np __free(device_node) = of_find_matching_node(node, its_device_id); np;
> np = of_find_matching_node(np, its_device_id)) {

Likewise.

> struct its_node *its;
>

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds