Skip to content

Commit 70ec177

Browse files
zijun-hujfvogel
authored andcommitted
of/irq: Fix device node refcount leakages in of_irq_init()
commit 708124d9e6e7ac5ebf927830760679136b23fdf0 upstream. of_irq_init() will leak interrupt controller device node refcounts in two places as explained below: 1) Leak refcounts of both @desc->dev and @desc->interrupt_parent when suffers @desc->irq_init_cb() failure. 2) Leak refcount of @desc->interrupt_parent when cleans up list @intc_desc_list in the end. Refcounts of both @desc->dev and @desc->interrupt_parent were got in the first loop, but of_irq_init() does not put them before kfree(@desc) in places mentioned above, so causes refcount leakages. Fix by putting refcounts involved before kfree(@desc). Fixes: 8363ccb ("of/irq: add missing of_node_put") Fixes: c71a54b ("of/irq: introduce of_irq_init") Cc: [email protected] Signed-off-by: Zijun Hu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Rob Herring (Arm) <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit 712d84459a53fc78f36ef44967f4cde4623b38f6) Signed-off-by: Jack Vogel <[email protected]>
1 parent 59b519b commit 70ec177

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/of/irq.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,8 @@ void __init of_irq_init(const struct of_device_id *matches)
632632
__func__, desc->dev, desc->dev,
633633
desc->interrupt_parent);
634634
of_node_clear_flag(desc->dev, OF_POPULATED);
635+
of_node_put(desc->interrupt_parent);
636+
of_node_put(desc->dev);
635637
kfree(desc);
636638
continue;
637639
}
@@ -662,6 +664,7 @@ void __init of_irq_init(const struct of_device_id *matches)
662664
err:
663665
list_for_each_entry_safe(desc, temp_desc, &intc_desc_list, list) {
664666
list_del(&desc->list);
667+
of_node_put(desc->interrupt_parent);
665668
of_node_put(desc->dev);
666669
kfree(desc);
667670
}

0 commit comments

Comments
 (0)