powerpc/powernv: Check kzalloc() return value in pnv_pci_table_alloc
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Mon, 27 Mar 2017 08:27:37 +0000 (19:27 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 28 Apr 2017 11:26:53 +0000 (21:26 +1000)
pnv_pci_table_alloc() ignores possible failure from kzalloc_node(),
this adds a check. There are 2 callers of pnv_pci_table_alloc(),
one already checks for tbl!=NULL, this adds WARN_ON() to the other path
which only happens during boot time in IODA1 and not expected to fail.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/platforms/powernv/pci-ioda.c
arch/powerpc/platforms/powernv/pci.c

index 93ce3f9d275869508d51e9ae86fd896ef85ca5a3..bc5466d447e7adf08f54f39d715c2f49e0b7ea4b 100644 (file)
@@ -2151,6 +2151,9 @@ static void pnv_pci_ioda1_setup_dma_pe(struct pnv_phb *phb,
 
 found:
        tbl = pnv_pci_table_alloc(phb->hose->node);
+       if (WARN_ON(!tbl))
+               return;
+
        iommu_register_group(&pe->table_group, phb->hose->global_number,
                        pe->pe_number);
        pnv_pci_link_table_and_group(phb->hose->node, 0, tbl, &pe->table_group);
index 9b2bdcad51ba039830de9d3c5490d380edc743e3..935ccb249a8ae21a8e8ee9f9af4793a5bf6b7394 100644 (file)
@@ -766,6 +766,9 @@ struct iommu_table *pnv_pci_table_alloc(int nid)
        struct iommu_table *tbl;
 
        tbl = kzalloc_node(sizeof(struct iommu_table), GFP_KERNEL, nid);
+       if (!tbl)
+               return NULL;
+
        INIT_LIST_HEAD_RCU(&tbl->it_group_list);
        kref_init(&tbl->it_kref);