Commit 70bb8437 authored by Felix Gu's avatar Felix Gu Committed by Bjorn Helgaas
Browse files

PCI/pwrctrl: Fix pci_pwrctrl_is_required() device node leak



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 release the reference.

Fixes: cf3287fb ("PCI/pwrctrl: Ensure that remote endpoint node parent has supply requirement")
Signed-off-by: default avatarFelix Gu <ustc.gu@gmail.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Reviewed-by: default avatarBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Reviewed-by: default avatarManivannan Sadhasivam <mani@kernel.org>
Link: https://patch.msgid.link/20260323-pwctrl-v1-1-f5c03a2df7fb@gmail.com
parent 2d8c5098
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -299,11 +299,13 @@ 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;
				}
			}
		}
	}

	return false;
}