From: Zijun Hu <quic_zijuhu@xxxxxxxxxxx> commit 3b9f942eb21c92041905e3943a8d5177c9a9d89d upstream. When removing a virtual Endpoint, pci_epf_remove_vepf() failed to clear epf_vf->epf_pf, which caused a subsequent pci_epf_add_vepf() to incorrectly return -EBUSY: pci_epf_add_vepf(epf_pf, epf_vf) // add pci_epf_remove_vepf(epf_pf, epf_vf) // remove pci_epf_add_vepf(epf_pf, epf_vf) // add again, -EBUSY error Fix by clearing epf_vf->epf_pf in pci_epf_remove_vepf(). Link: https://lore.kernel.org/r/20241210-pci-epc-core_fix-v3-3-4d86dd573e4b@xxxxxxxxxxx Fixes: 1cf362e907f3 ("PCI: endpoint: Add support to add virtual function in endpoint core") Signed-off-by: Zijun Hu <quic_zijuhu@xxxxxxxxxxx> Signed-off-by: Bjorn Helgaas <bhelgaas@xxxxxxxxxx> Reviewed-by: Frank Li <Frank.Li@xxxxxxx> Cc: stable@xxxxxxxxxxxxxxx Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/pci/endpoint/pci-epf-core.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/pci/endpoint/pci-epf-core.c +++ b/drivers/pci/endpoint/pci-epf-core.c @@ -234,6 +234,7 @@ void pci_epf_remove_vepf(struct pci_epf mutex_lock(&epf_pf->lock); clear_bit(epf_vf->vfunc_no, &epf_pf->vfunction_num_map); + epf_vf->epf_pf = NULL; list_del(&epf_vf->list); mutex_unlock(&epf_pf->lock); } Patches currently in stable-queue which might be from quic_zijuhu@xxxxxxxxxxx are queue-5.15/pci-endpoint-finish-virtual-ep-removal-in-pci_epf_remove_vepf.patch queue-5.15/of-reserved-memory-fix-using-wrong-number-of-cells-to-get-property-alignment.patch queue-5.15/of-fix-of_find_node_opts_by_path-handling-of-alias-path-options.patch queue-5.15/pci-endpoint-destroy-the-epc-device-in-devm_pci_epc_.patch queue-5.15/of-reserved-memory-do-not-make-kmemleak-ignore-freed.patch queue-5.15/blk-cgroup-fix-class-block_class-s-subsystem-refcount-leakage.patch queue-5.15/of-correct-child-specifier-used-as-input-of-the-2nd-nexus-node.patch