[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241209-of_irq_fix-v1-6-782f1419c8a1@quicinc.com>
Date: Mon, 09 Dec 2024 21:25:04 +0800
From: Zijun Hu <zijun_hu@...oud.com>
To: Rob Herring <robh@...nel.org>, Saravana Kannan <saravanak@...gle.com>,
Lorenzo Pieralisi <lpieralisi@...nel.org>,
Bjorn Helgaas <bhelgaas@...gle.com>, Marc Zyngier <maz@...nel.org>,
Stefan Wiehler <stefan.wiehler@...ia.com>,
Grant Likely <grant.likely@...aro.org>, Tony Lindgren <tony@...mide.com>,
Kumar Gala <galak@...eaurora.org>,
Thierry Reding <thierry.reding@...il.com>,
Julia Lawall <Julia.Lawall@...6.fr>, Jamie Iles <jamie@...ieiles.com>,
Grant Likely <grant.likely@...retlab.ca>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>
Cc: Zijun Hu <zijun_hu@...oud.com>, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, Rob Herring <rob.herring@...xeda.com>,
Zijun Hu <quic_zijuhu@...cinc.com>, stable@...r.kernel.org
Subject: [PATCH 6/8] of/irq: Fix device node refcount leakages in
of_irq_count()
From: Zijun Hu <quic_zijuhu@...cinc.com>
For of_irq_count(), successful of_irq_parse_one() invocation will get
device node @irq.np refcount,
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@...r.kernel.org
Signed-off-by: Zijun Hu <quic_zijuhu@...cinc.com>
---
drivers/of/irq.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index e5a9e24a5bd3606a57a07d0d12d3e774e9c78977..d917924d80f563e1392cedc616843365bc638f16 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -514,8 +514,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;
}
--
2.34.1
Powered by blists - more mailing lists