[PATCH] PCI/pwrctrl: Fix device node leak in pci_pwrctrl_is_required()
From: Felix Gu
Date: Mon Mar 23 2026 - 07:13:05 EST
The for_each_endpoint_of_node() macro requires calling of_node_put() on
the endpoint node when breaking out of the loop early.
Add of_node_put(endpoint) before the early return to properly release
the reference.
Fixes: cf3287fb2c1f ("PCI/pwrctrl: Ensure that remote endpoint node parent has supply requirement")
Signed-off-by: Felix Gu <ustc.gu@xxxxxxxxx>
---
drivers/pci/pwrctrl/core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/pwrctrl/core.c b/drivers/pci/pwrctrl/core.c
index 7754baed67f2..97cff5b8ca88 100644
--- a/drivers/pci/pwrctrl/core.c
+++ b/drivers/pci/pwrctrl/core.c
@@ -299,8 +299,10 @@ static bool pci_pwrctrl_is_required(struct device_node *np)
struct device_node *remote __free(device_node) =
of_graph_get_remote_port_parent(endpoint);
if (remote) {
- if (of_pci_supply_present(remote))
+ if (of_pci_supply_present(remote)) {
+ of_node_put(endpoint);
return true;
+ }
}
}
}
---
base-commit: 785f0eb2f85decbe7c1ef9ae922931f0194ffc2e
change-id: 20260323-pwctrl-fe840d733443
Best regards,
--
Felix Gu <ustc.gu@xxxxxxxxx>