Skip to content

Commit 6caa5a2

Browse files
YuuoniyMarc Zyngier
authored andcommitted
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: f8410e6 ("irqchip: Add IRQCHIP_PLATFORM_DRIVER_BEGIN/END and IRQCHIP_MATCH helper macros") Signed-off-by: Miaoqian Lin <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5dc4c99 commit 6caa5a2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/irqchip/irqchip.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ int platform_irqchip_probe(struct platform_device *pdev)
3838
struct device_node *par_np = of_irq_find_parent(np);
3939
of_irq_init_cb_t irq_init_cb = of_device_get_match_data(&pdev->dev);
4040

41-
if (!irq_init_cb)
41+
if (!irq_init_cb) {
42+
of_node_put(par_np);
4243
return -EINVAL;
44+
}
4345

4446
if (par_np == np)
4547
par_np = NULL;
@@ -52,8 +54,10 @@ int platform_irqchip_probe(struct platform_device *pdev)
5254
* interrupt controller. The actual initialization callback of this
5355
* interrupt controller can check for specific domains as necessary.
5456
*/
55-
if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY))
57+
if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY)) {
58+
of_node_put(par_np);
5659
return -EPROBE_DEFER;
60+
}
5761

5862
return irq_init_cb(np, par_np);
5963
}

0 commit comments

Comments
 (0)