Alexey Kardashevskiy <a...@ozlabs.ru> writes: > pnv_pci_table_alloc() ignores posible 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 BUG_ON() to the other path > which only happens during boot time in IODA1 and not expected to fail. > > Fixes: 0eaf4defc7c4 ("powerpc/spapr: vfio: Switch from iommu_table to new > iommu_table_group") > Signed-off-by: Alexey Kardashevskiy <a...@ozlabs.ru> > --- > arch/powerpc/platforms/powernv/pci-ioda.c | 1 + > arch/powerpc/platforms/powernv/pci.c | 3 +++ > 2 files changed, 4 insertions(+) > > diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c > b/arch/powerpc/platforms/powernv/pci-ioda.c > index e36738291c32..dcda3f6b7d36 100644 > --- a/arch/powerpc/platforms/powernv/pci-ioda.c > +++ b/arch/powerpc/platforms/powernv/pci-ioda.c > @@ -2128,6 +2128,7 @@ static void pnv_pci_ioda1_setup_dma_pe(struct pnv_phb > *phb, > > found: > tbl = pnv_pci_table_alloc(phb->hose->node); > + BUG_ON(!tbl); > 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);
Please don't add BUG_ON()'s for non-critical things like this. I know memory allocation isn't expected to fail during boot, but don't make people's life harder by BUG'ing. Ideally you'd just return failure to the caller and eventually we'd print a message at some higher level. In a case like this where the function returns void, rather than restructuring everything to pass a return value you can just do: if (WARN_ON(!tbl)) return; cheers