Re: [PATCH] PCI/pwrctrl: Fix device node leak in pci_pwrctrl_is_required()
From: Manivannan Sadhasivam
Date: Mon Mar 23 2026 - 08:11:59 EST
On Mon, Mar 23, 2026 at 07:05:22PM +0800, Felix Gu wrote:
> 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>
Err...
Reviewed-by: Manivannan Sadhasivam <mani@xxxxxxxxxx>
- Mani
> ---
> 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>
>
--
மணிவண்ணன் சதாசிவம்