irqchip/realtek-rtl: Fix refcount leak in map_interrupts
authorMiaoqian Lin <linmq006@gmail.com>
Wed, 1 Jun 2022 08:09:30 +0000 (12:09 +0400)
committerMarc Zyngier <maz@kernel.org>
Thu, 9 Jun 2022 16:36:57 +0000 (17:36 +0100)
of_find_node_by_phandle() returns a node pointer with refcount
incremented, we should use of_node_put() on it when not need anymore.
This function doesn't call of_node_put() in error path.
Call of_node_put() directly after of_property_read_u32() to cover
both normal path and error path.

Fixes: 9f3a0f34b84a ("irqchip: Add support for Realtek RTL838x/RTL839x interrupt controller")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20220601080930.31005-7-linmq006@gmail.com
drivers/irqchip/irq-realtek-rtl.c

index 50a5682..56bf502 100644 (file)
@@ -134,9 +134,9 @@ static int __init map_interrupts(struct device_node *node, struct irq_domain *do
                if (!cpu_ictl)
                        return -EINVAL;
                ret = of_property_read_u32(cpu_ictl, "#interrupt-cells", &tmp);
+               of_node_put(cpu_ictl);
                if (ret || tmp != 1)
                        return -EINVAL;
-               of_node_put(cpu_ictl);
 
                cpu_int = be32_to_cpup(imap + 2);
                if (cpu_int > 7 || cpu_int < 2)