PCI: endpoint: Set endpoint controller pointer to NULL
authorAlan Mikhak <alan.mikhak@sifive.com>
Thu, 23 May 2019 21:45:44 +0000 (14:45 -0700)
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Tue, 11 Jun 2019 09:55:12 +0000 (10:55 +0100)
Set endpoint controller pointer to NULL in pci_epc_remove_epf()
to avoid -EBUSY on subsequent call to pci_epc_add_epf().

Add a check for NULL endpoint function pointer.

Signed-off-by: Alan Mikhak <alan.mikhak@sifive.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
drivers/pci/endpoint/pci-epc-core.c

index e4712a0f249cb72c2d4a6c65a17ba96755e593cf..2091508c16204d43e42fa879f700ccea1538e3e2 100644 (file)
@@ -519,11 +519,12 @@ void pci_epc_remove_epf(struct pci_epc *epc, struct pci_epf *epf)
 {
        unsigned long flags;
 
-       if (!epc || IS_ERR(epc))
+       if (!epc || IS_ERR(epc) || !epf)
                return;
 
        spin_lock_irqsave(&epc->lock, flags);
        list_del(&epf->list);
+       epf->epc = NULL;
        spin_unlock_irqrestore(&epc->lock, flags);
 }
 EXPORT_SYMBOL_GPL(pci_epc_remove_epf);