Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

irqchip: Fix refcount leak in platform_irqchip_probe

of_irq_find_parent() returns a node pointer with refcount incremented,
We should use of_node_put() on it when not needed anymore.
Add missing of_node_put() to avoid refcount leak.

Fixes: f8410e626569 ("irqchip: Add IRQCHIP_PLATFORM_DRIVER_BEGIN/END and IRQCHIP_MATCH helper macros")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20230102121318.3990586-1-linmq006@gmail.com

authored by

Miaoqian Lin and committed by
Marc Zyngier
6caa5a2b 5dc4c995

+6 -2
+6 -2
drivers/irqchip/irqchip.c
··· 38 38 struct device_node *par_np = of_irq_find_parent(np); 39 39 of_irq_init_cb_t irq_init_cb = of_device_get_match_data(&pdev->dev); 40 40 41 - if (!irq_init_cb) 41 + if (!irq_init_cb) { 42 + of_node_put(par_np); 42 43 return -EINVAL; 44 + } 43 45 44 46 if (par_np == np) 45 47 par_np = NULL; ··· 54 52 * interrupt controller. The actual initialization callback of this 55 53 * interrupt controller can check for specific domains as necessary. 56 54 */ 57 - if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY)) 55 + if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY)) { 56 + of_node_put(par_np); 58 57 return -EPROBE_DEFER; 58 + } 59 59 60 60 return irq_init_cb(np, par_np); 61 61 }