]> git.hungrycats.org Git - linux/commitdiff
of/irq: Fix device node refcount leak in of_irq_get_affinity()
authorFuad Tabba <fuad.tabba@linux.dev>
Wed, 26 Aug 2026 11:22:34 +0000 (12:22 +0100)
committerRob Herring (Arm) <robh@kernel.org>
Wed, 26 Aug 2026 14:49:03 +0000 (09:49 -0500)
of_irq_parse_one() raises the refcount of the interrupt controller node
on success, and of_irq_get_affinity() returns without putting it, so
every call past the parse leaks one reference. It is reached from
platform_get_irq_affinity(), used by arm_pmu, arm_spe_pmu and
coresight-trbe.

Put it once irq_populate_fwspec_info() has run: no in-tree
->get_fwspec_info() returns a mask that lives in the node.

Fixes: 5404f5c06dd4 ("of/irq: Add interrupt affinity reporting interface")
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
Link: https://patch.msgid.link/20260826112234.1033974-1-fuad.tabba@linux.dev
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
drivers/of/irq.c

index 967c191008797f0fbe0687bd07e95101761589d6..ec035367c9500c726a88b4900a7469d28344228b 100644 (file)
@@ -563,7 +563,9 @@ const struct cpumask *of_irq_get_affinity(struct device_node *dev, int index)
        of_phandle_args_to_fwspec(oirq.np, oirq.args, oirq.args_count,
                                  &fwspec);
 
-       if (irq_populate_fwspec_info(&fwspec, &info))
+       rc = irq_populate_fwspec_info(&fwspec, &info);
+       of_node_put(oirq.np);
+       if (rc)
                return NULL;
 
        return info.affinity;