irqchip: Plug a OF node reference leak in platform_irqchip_probe()

platform_irqchip_probe() leaks a OF node when irq_init_cb() fails. Fix it
by declaring par_np with the __free(device_node) cleanup construct.

This bug was found by an experimental static analysis tool that I am
developing.

Fixes: f8410e626569 ("irqchip: Add IRQCHIP_PLATFORM_DRIVER_BEGIN/END and IRQCHIP_MATCH helper macros")
Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/all/20241215033945.3414223-1-joe@pf.is.s.u-tokyo.ac.jp

authored by Joe Hattori and committed by Thomas Gleixner 9322d191 3a748d48

Changed files
+1 -3
drivers
irqchip
+1 -3
drivers/irqchip/irqchip.c
··· 35 35 int platform_irqchip_probe(struct platform_device *pdev) 36 36 { 37 37 struct device_node *np = pdev->dev.of_node; 38 - struct device_node *par_np = of_irq_find_parent(np); 38 + struct device_node *par_np __free(device_node) = 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 41 if (!irq_init_cb) { 42 - of_node_put(par_np); 43 42 return -EINVAL; 44 43 } 45 44 ··· 54 55 * interrupt controller can check for specific domains as necessary. 55 56 */ 56 57 if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY)) { 57 - of_node_put(par_np); 58 58 return -EPROBE_DEFER; 59 59 } 60 60