[PATCH 3/3] PCI: keystone: Fix device node leak in ks_pcie_am654_set_mode()
From: zhaofeng2
Date: Tue Nov 10 2026 - 05:31:17 EST
From: Zhao Feng <zhaofeng2@xxxxxxxxxxxxxxxxxxxx>
ks_pcie_am654_set_mode() resolves the "ti,syscon-pcie-mode" phandle
with of_parse_phandle_with_fixed_args() to obtain the mode register
offset, which takes a reference on the syscon device node, but the
reference is never dropped after the offset has been read from
args.args[0], so the syscon node is leaked on every probe.
Drop the reference with of_node_put() once the offset argument has
been consumed.
Fixes: 7dcf07ac8867 ("PCI: keystone: Use phandle argument from "ti,syscon-pcie-id"/"ti,syscon-pcie-mode"")
Signed-off-by: Zhao Feng <zhaofeng2@xxxxxxxxxxxxxxxxxxxx>
---
drivers/pci/controller/dwc/pci-keystone.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletions(-)
diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c
--- a/drivers/pci/controller/dwc/pci-keystone.c
+++ b/drivers/pci/controller/dwc/pci-keystone.c
@@ -1059,8 +1059,10 @@
/* Do not error out to maintain old DT compatibility */
ret = of_parse_phandle_with_fixed_args(np, "ti,syscon-pcie-mode", 1, 0, &args);
- if (!ret)
+ if (!ret) {
offset = args.args[0];
+ of_node_put(args.np);
+ }
mask = AM654_PCIE_DEV_TYPE_MASK;