PCI: endpoint: Destroy the EPC device in devm_pci_epc_destroy()
authorZijun Hu <quic_zijuhu@quicinc.com>
Tue, 10 Dec 2024 14:00:18 +0000 (22:00 +0800)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 12 Dec 2024 19:04:08 +0000 (13:04 -0600)
The devm_pci_epc_destroy() comment says destroys the EPC device, but it
does not actually do that since devres_destroy() does not call
devm_pci_epc_release(), and it also can not fully undo what the API
devm_pci_epc_create() does, so it is faulty.

Fortunately, the faulty API has not been used by current kernel tree.  Use
devres_release() instead of devres_destroy() so the EPC device will be
released.

Link: https://lore.kernel.org/r/20241210-pci-epc-core_fix-v3-1-4d86dd573e4b@quicinc.com
Fixes: 5e8cb4033807 ("PCI: endpoint: Add EP core layer to enable EP controller and EP functions")
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/endpoint/pci-epc-core.c

index bed7c7d1fe3c372125c7661082f87c9c89383703..75c66882900343a112064ab72b6f5e4a8235e2c2 100644 (file)
@@ -942,7 +942,7 @@ void devm_pci_epc_destroy(struct device *dev, struct pci_epc *epc)
 {
        int r;
 
-       r = devres_destroy(dev, devm_pci_epc_release, devm_pci_epc_match,
+       r = devres_release(dev, devm_pci_epc_release, devm_pci_epc_match,
                           epc);
        dev_WARN_ONCE(dev, r, "couldn't find PCI EPC resource\n");
 }