7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shawn Lin [ Upstream commit 7bf2ebcb7ca1e8814d3d0e35214a8e4b2193a619 ] pci_pwrctrl_create_device() only creates platform devices for OF nodes that pci_pwrctrl_is_required() accepts, but pci_pwrctrl_destroy_device() unregisters the platform device of every available child node without that check. Nodes under a PCI host controller that are not pwrctrl devices may have been populated by another mechanism. Destroying them here would tear down devices owned by other code. Mirror the check done at creation time so that only devices created by the pwrctrl core are removed. Fixes: 4c4132489201 ("PCI/pwrctrl: Add APIs to create, destroy pwrctrl devices") Signed-off-by: Shawn Lin Signed-off-by: Bjorn Helgaas Reviewed-by: Bartosz Golaszewski Cc: stable@vger.kernel.org Link: https://patch.msgid.link/1791446700-100166-1-git-send-email-shawn.lin@rock-chips.com Signed-off-by: Sasha Levin --- drivers/pci/pwrctrl/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/pwrctrl/core.c b/drivers/pci/pwrctrl/core.c index 10d817aefb096..c14df117ece37 100644 --- a/drivers/pci/pwrctrl/core.c +++ b/drivers/pci/pwrctrl/core.c @@ -388,6 +388,9 @@ static void pci_pwrctrl_destroy_device(struct device_node *np) for_each_available_child_of_node_scoped(np, child) pci_pwrctrl_destroy_device(child); + if (!pci_pwrctrl_is_required(np)) + return; + pdev = of_find_device_by_node(np); if (!pdev) return; -- 2.53.0