From: Zijun Hu Date: Sun, 9 Feb 2025 12:58:58 +0000 (+0800) Subject: of/irq: Fix device node refcount leakages in of_irq_count() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=bbf71f44aaf241d853759a71de7e7ebcdb89be3d;p=users%2Fwilly%2Flinux.git of/irq: Fix device node refcount leakages in of_irq_count() of_irq_count() invokes of_irq_parse_one() to count IRQs, and successful invocation of the later will get device node @irq.np refcount, but the former does not put the refcount before next iteration invocation, hence causes device node refcount leakages. Fix by putting @irq.np refcount before the next iteration invocation. Fixes: 3da5278727a8 ("of/irq: Rework of_irq_count()") Cc: stable@vger.kernel.org Signed-off-by: Zijun Hu Link: https://lore.kernel.org/r/20250209-of_irq_fix-v2-5-93e3a2659aa7@quicinc.com Signed-off-by: Rob Herring (Arm) --- diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 1a018726fb0e..75b471327903 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -508,8 +508,10 @@ int of_irq_count(struct device_node *dev) struct of_phandle_args irq; int nr = 0; - while (of_irq_parse_one(dev, nr, &irq) == 0) + while (of_irq_parse_one(dev, nr, &irq) == 0) { + of_node_put(irq.np); nr++; + } return nr; }