[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Xen-devel] [PATCH 19/21] treewide: add checks for the return value of memblock_alloc*()
- To: Mike Rapoport <rppt@xxxxxxxxxxxxx>
- From: Paul Burton <paul.burton@xxxxxxxx>
- Date: Fri, 18 Jan 2019 18:02:03 +0000
- Accept-language: en-US
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=pburton@xxxxxxxxxxxx;
- Cc: Rich Felker <dalias@xxxxxxxx>, "linux-ia64@xxxxxxxxxxxxxxx" <linux-ia64@xxxxxxxxxxxxxxx>, "devicetree@xxxxxxxxxxxxxxx" <devicetree@xxxxxxxxxxxxxxx>, Catalin Marinas <catalin.marinas@xxxxxxx>, Heiko Carstens <heiko.carstens@xxxxxxxxxx>, "x86@xxxxxxxxxx" <x86@xxxxxxxxxx>, "linux-mips@xxxxxxxxxxxxxxx" <linux-mips@xxxxxxxxxxxxxxx>, Max Filippov <jcmvbkbc@xxxxxxxxx>, Guo Ren <guoren@xxxxxxxxxx>, "sparclinux@xxxxxxxxxxxxxxx" <sparclinux@xxxxxxxxxxxxxxx>, Christoph Hellwig <hch@xxxxxx>, "linux-s390@xxxxxxxxxxxxxxx" <linux-s390@xxxxxxxxxxxxxxx>, "linux-c6x-dev@xxxxxxxxxxxxx" <linux-c6x-dev@xxxxxxxxxxxxx>, Yoshinori Sato <ysato@xxxxxxxxxxxxxxxxxxxx>, Richard Weinberger <richard@xxxxxx>, "linux-sh@xxxxxxxxxxxxxxx" <linux-sh@xxxxxxxxxxxxxxx>, Russell King <linux@xxxxxxxxxxxxxxx>, "kasan-dev@xxxxxxxxxxxxxxxx" <kasan-dev@xxxxxxxxxxxxxxxx>, Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>, Mark Salter <msalter@xxxxxxxxxx>, Dennis Zhou <dennis@xxxxxxxxxx>, Matt Turner <mattst88@xxxxxxxxx>, "linux-snps-arc@xxxxxxxxxxxxxxxxxxx" <linux-snps-arc@xxxxxxxxxxxxxxxxxxx>, "uclinux-h8-devel@xxxxxxxxxxxxxxxxxxxx" <uclinux-h8-devel@xxxxxxxxxxxxxxxxxxxx>, Petr Mladek <pmladek@xxxxxxxx>, "linux-xtensa@xxxxxxxxxxxxxxxx" <linux-xtensa@xxxxxxxxxxxxxxxx>, "linux-alpha@xxxxxxxxxxxxxxx" <linux-alpha@xxxxxxxxxxxxxxx>, "linux-um@xxxxxxxxxxxxxxxxxxx" <linux-um@xxxxxxxxxxxxxxxxxxx>, "linux-m68k@xxxxxxxxxxxxxxxxxxxx" <linux-m68k@xxxxxxxxxxxxxxxxxxxx>, Rob Herring <robh+dt@xxxxxxxxxx>, Greentime Hu <green.hu@xxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stafford Horne <shorne@xxxxxxxxx>, Guan Xuetao <gxt@xxxxxxxxxx>, "linux-arm-kernel@xxxxxxxxxxxxxxxxxxx" <linux-arm-kernel@xxxxxxxxxxxxxxxxxxx>, Michal Simek <monstr@xxxxxxxxx>, Tony Luck <tony.luck@xxxxxxxxx>, "linux-mm@xxxxxxxxx" <linux-mm@xxxxxxxxx>, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>, "linux-usb@xxxxxxxxxxxxxxx" <linux-usb@xxxxxxxxxxxxxxx>, "linux-kernel@xxxxxxxxxxxxxxx" <linux-kernel@xxxxxxxxxxxxxxx>, Vineet Gupta <vgupta@xxxxxxxxxxxx>, Michael Ellerman <mpe@xxxxxxxxxxxxxx>, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, "linuxppc-dev@xxxxxxxxxxxxxxxx" <linuxppc-dev@xxxxxxxxxxxxxxxx>, "David S. Miller" <davem@xxxxxxxxxxxxx>, "openrisc@xxxxxxxxxxxxxxxxxxxx" <openrisc@xxxxxxxxxxxxxxxxxxxx>
- Delivery-date: Sat, 19 Jan 2019 06:48:09 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
- Thread-index: AQHUraHd8jRLB7x3YEeU6EKybqgDLKW1VI6A
- Thread-topic: [PATCH 19/21] treewide: add checks for the return value of memblock_alloc*()
Hi Mike,
On Wed, Jan 16, 2019 at 03:44:19PM +0200, Mike Rapoport wrote:
> 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);
>
> Signed-off-by: Mike Rapoport <rppt@xxxxxxxxxxxxx>
> ---
>%
> diff --git a/arch/mips/cavium-octeon/dma-octeon.c
> b/arch/mips/cavium-octeon/dma-octeon.c
> index e8eb60e..db1deb2 100644
> --- a/arch/mips/cavium-octeon/dma-octeon.c
> +++ b/arch/mips/cavium-octeon/dma-octeon.c
> @@ -245,6 +245,9 @@ void __init plat_swiotlb_setup(void)
> swiotlbsize = swiotlb_nslabs << IO_TLB_SHIFT;
>
> octeon_swiotlb = memblock_alloc_low(swiotlbsize, PAGE_SIZE);
> + if (!octeon_swiotlb)
> + panic("%s: Failed to allocate %lu bytes align=%lx\n",
> + __func__, swiotlbsize, PAGE_SIZE);
>
> if (swiotlb_init_with_tbl(octeon_swiotlb, swiotlb_nslabs, 1) == -ENOMEM)
> panic("Cannot allocate SWIOTLB buffer");
That one should be %zu rather than %lu. The rest looks good, so with
that one tweak:
Acked-by: Paul Burton <paul.burton@xxxxxxxx> # MIPS parts
Thanks,
Paul
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|