Skip to content

Commit 9322d19

Browse files
joehattoriKAGA-KOKO
authored andcommitted
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: f8410e6 ("irqchip: Add IRQCHIP_PLATFORM_DRIVER_BEGIN/END and IRQCHIP_MATCH helper macros") Signed-off-by: Joe Hattori <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/all/[email protected]
1 parent 3a748d4 commit 9322d19

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/irqchip/irqchip.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@ void __init irqchip_init(void)
3535
int platform_irqchip_probe(struct platform_device *pdev)
3636
{
3737
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);
3939
of_irq_init_cb_t irq_init_cb = of_device_get_match_data(&pdev->dev);
4040

4141
if (!irq_init_cb) {
42-
of_node_put(par_np);
4342
return -EINVAL;
4443
}
4544

@@ -55,7 +54,6 @@ int platform_irqchip_probe(struct platform_device *pdev)
5554
* interrupt controller can check for specific domains as necessary.
5655
*/
5756
if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY)) {
58-
of_node_put(par_np);
5957
return -EPROBE_DEFER;
6058
}
6159

0 commit comments

Comments
 (0)