From 7bf2ebcb7ca1e8814d3d0e35214a8e4b2193a619 Mon Sep 17 00:00:00 2001 From: Shawn Lin Date: Thu, 8 Oct 2026 16:05:00 +0800 Subject: [PATCH] PCI/pwrctrl: Only destroy devices created by pwrctrl core 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 --- 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 10d817aefb09..c14df117ece3 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;