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

Configure Feed

Select the types of activity you want to include in your feed.

of/irq: Fix device node refcount leakages in of_irq_init()

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: 8363ccb917c6 ("of/irq: add missing of_node_put")
Fixes: c71a54b08201 ("of/irq: introduce of_irq_init")
Cc: stable@vger.kernel.org
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Link: https://lore.kernel.org/r/20250209-of_irq_fix-v2-7-93e3a2659aa7@quicinc.com
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>

authored by

Zijun Hu and committed by
Rob Herring (Arm)
708124d9 962a2805

+3
+3
drivers/of/irq.c
··· 632 632 __func__, desc->dev, desc->dev, 633 633 desc->interrupt_parent); 634 634 of_node_clear_flag(desc->dev, OF_POPULATED); 635 + of_node_put(desc->interrupt_parent); 636 + of_node_put(desc->dev); 635 637 kfree(desc); 636 638 continue; 637 639 } ··· 664 662 err: 665 663 list_for_each_entry_safe(desc, temp_desc, &intc_desc_list, list) { 666 664 list_del(&desc->list); 665 + of_node_put(desc->interrupt_parent); 667 666 of_node_put(desc->dev); 668 667 kfree(desc); 669 668 }