treewide: add checks for the return value of memblock_alloc*()
Add check for the return value of memblock_alloc*() functions and call panic() in case of error. The panic message repeats the one used by panicing memblock allocators with adjustment of parameters to include only relevant ones. The replacement was mostly automated with semantic patches like the one below with manual massaging of format strings. @@ expression ptr, size, align; @@ ptr = memblock_alloc(size, align); + if (!ptr) + panic("%s: Failed to allocate %lu bytes align=0x%lx\n", __func__, size, align); [anders.roxell@linaro.org: use '%pa' with 'phys_addr_t' type] Link: http://lkml.kernel.org/r/20190131161046.21886-1-anders.roxell@linaro.org [rppt@linux.ibm.com: fix format strings for panics after memblock_alloc] Link: http://lkml.kernel.org/r/1548950940-15145-1-git-send-email-rppt@linux.ibm.com [rppt@linux.ibm.com: don't panic if the allocation in sparse_buffer_init fails] Link: http://lkml.kernel.org/r/2019013107401...
Showing
- arch/alpha/kernel/core_cia.c 3 additions, 0 deletionsarch/alpha/kernel/core_cia.c
- arch/alpha/kernel/core_marvel.c 6 additions, 0 deletionsarch/alpha/kernel/core_marvel.c
- arch/alpha/kernel/pci-noop.c 11 additions, 2 deletionsarch/alpha/kernel/pci-noop.c
- arch/alpha/kernel/pci.c 10 additions, 1 deletionarch/alpha/kernel/pci.c
- arch/alpha/kernel/pci_iommu.c 12 additions, 0 deletionsarch/alpha/kernel/pci_iommu.c
- arch/arc/mm/highmem.c 4 additions, 0 deletionsarch/arc/mm/highmem.c
- arch/arm/kernel/setup.c 6 additions, 0 deletionsarch/arm/kernel/setup.c
- arch/arm/mm/mmu.c 13 additions, 1 deletionarch/arm/mm/mmu.c
- arch/arm64/kernel/setup.c 5 additions, 3 deletionsarch/arm64/kernel/setup.c
- arch/arm64/mm/kasan_init.c 10 additions, 0 deletionsarch/arm64/mm/kasan_init.c
- arch/c6x/mm/dma-coherent.c 4 additions, 0 deletionsarch/c6x/mm/dma-coherent.c
- arch/c6x/mm/init.c 3 additions, 0 deletionsarch/c6x/mm/init.c
- arch/csky/mm/highmem.c 5 additions, 0 deletionsarch/csky/mm/highmem.c
- arch/h8300/mm/init.c 3 additions, 0 deletionsarch/h8300/mm/init.c
- arch/m68k/atari/stram.c 4 additions, 0 deletionsarch/m68k/atari/stram.c
- arch/m68k/mm/init.c 3 additions, 0 deletionsarch/m68k/mm/init.c
- arch/m68k/mm/mcfmmu.c 6 additions, 0 deletionsarch/m68k/mm/mcfmmu.c
- arch/m68k/mm/motorola.c 9 additions, 0 deletionsarch/m68k/mm/motorola.c
- arch/m68k/mm/sun3mmu.c 6 additions, 0 deletionsarch/m68k/mm/sun3mmu.c
- arch/m68k/sun3/sun3dvma.c 3 additions, 0 deletionsarch/m68k/sun3/sun3dvma.c
Please register or sign in to comment