cxl: Free virtual PHB when removing
authorAndrew Donnellan <andrew.donnellan@au1.ibm.com>
Tue, 13 Oct 2015 04:09:44 +0000 (15:09 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 15 Oct 2015 09:31:58 +0000 (20:31 +1100)
When adding a vPHB in cxl_pci_vphb_add(), we allocate a pci_controller
struct using pcibios_alloc_controller(). However, we don't free it in
cxl_pci_vphb_remove(), causing a leak.

Call pcibios_free_controller() in cxl_pci_vphb_remove() to free the vPHB
data structure correctly.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
drivers/misc/cxl/vphb.c

index 94b5208..c241e15 100644 (file)
@@ -290,8 +290,10 @@ void cxl_pci_vphb_remove(struct cxl_afu *afu)
                return;
 
        phb = afu->phb;
+       afu->phb = NULL;
 
        pci_remove_root_bus(phb->bus);
+       pcibios_free_controller(phb);
 }
 
 struct cxl_afu *cxl_pci_to_afu(struct pci_dev *dev)