Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH] PCI: apple: Fix device node leak in apple_msi_init()
@ 2026-12-03  4:20 Yuwei Chen
  2026-12-03  4:37 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Yuwei Chen @ 2026-12-03  4:20 UTC (permalink / raw)
  To: Marc Zyngier; +Cc: Bjorn Helgaas, linux-pci

apple_msi_init() takes a reference on the parent interrupt controller
node with of_parse_phandle_with_args().  of_phandle_args_to_fwspec()
only copies the node pointer into pcie->fwspec, it does not take
another reference, and nothing in the driver drops the one returned by
the parse.  That reference is also still held on the error return that
follows the "msi-ranges" parse.

Drop it once the fwspec has been filled, and on that earlier error
return.

Fixes: 476c41ed4597 ("PCI: apple: Implement MSI support")
Cc: stable@vger.kernel.org
Signed-off-by: Yuwei Chen <2522445001@qq.com>
---
 drivers/pci/controller/pcie-apple.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
index dfd0e345bc56..9a6d2e1e8eb4 100644
--- a/drivers/pci/controller/pcie-apple.c
+++ b/drivers/pci/controller/pcie-apple.c
@@ -697,11 +697,14 @@ static int apple_msi_init(struct apple_pcie *pcie)
 
 	ret = of_property_read_u32_index(to_of_node(fwnode), "msi-ranges",
 					 args.args_count + 1, &pcie->nvecs);
-	if (ret)
+	if (ret) {
+		of_node_put(args.np);
 		return ret;
+	}
 
 	of_phandle_args_to_fwspec(args.np, args.args, args.args_count,
 				  &pcie->fwspec);
+	of_node_put(args.np);
 
 	pcie->bitmap = devm_bitmap_zalloc(pcie->dev, pcie->nvecs, GFP_KERNEL);
 	if (!pcie->bitmap)
base-commit: 3dbdc13bd4b313b3d94c0f719378a4641a39db46
-- 
2.55.0.windows.3


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

end of thread, other threads:[~2026-12-03  4:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03  4:20 [PATCH] PCI: apple: Fix device node leak in apple_msi_init() Yuwei Chen
2026-12-03  4:37 ` sashiko-bot

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