Devicetree
 help / color / mirror / Atom feed
* [PATCH] of/irq: Fix device node refcount leak in of_check_msi_parent()
@ 2026-09-04  7:34 Fuad Tabba
  2026-09-04  7:48 ` sashiko-bot
  0 siblings, 1 reply; 5+ messages in thread
From: Fuad Tabba @ 2026-09-04  7:34 UTC (permalink / raw)
  To: Rob Herring, Saravana Kannan
  Cc: Lorenzo Pieralisi, Frank Li, devicetree, linux-kernel, Fuad Tabba

of_msi_xlate() documents @msi_np as a filter when it points at a node on
entry, handing back a reference only when it points at NULL. The msi-map
branch does that. of_check_msi_parent() keeps the reference from the 1:1
msi-parent match either way.

pci_msi_domain_get_msi_rid() is the only caller that passes a node in,
from irq_domain_get_of_node(), and it puts nothing, so a 1:1 match there
leaks the MSI controller node.

Fixes: 119aaeed0b67 ("of/irq: Add msi-parent check to of_msi_xlate()")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/all/20260826113604.010C01F000E9@smtp.kernel.org/
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
---
 drivers/of/irq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index ec035367c9500..109c54f346479 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -785,7 +785,7 @@ static int of_check_msi_parent(struct device_node *dev_node, struct device_node
 	if ((*msi_node && *msi_node != msi_spec.np) || msi_spec.args_count != 0)
 		ret = -EINVAL;
 
-	if (!ret) {
+	if (!ret && !*msi_node) {
 		/* Return with a node reference held */
 		*msi_node = msi_spec.np;
 		return 0;
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-09-04 12:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-04  7:34 [PATCH] of/irq: Fix device node refcount leak in of_check_msi_parent() Fuad Tabba
2026-09-04  7:48 ` sashiko-bot
2026-09-04  9:25   ` Fuad Tabba
2026-09-04 11:11     ` Lorenzo Pieralisi
2026-09-04 12:48       ` Fuad Tabba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox