Re: [PATCH] x86, olpc: Eliminate BUG_ON and memset after alloc_bootmem

From: David Rientjes
Date: Mon Jul 21 2014 - 18:56:55 EST


On Sat, 19 Jul 2014, Himangi Saraogi wrote:

> alloc_bootmem and related functions never return NULL and always return
> a zeroed region of memory. Thus a BUG_ON the NULL test or memset after
> calls to these functions is unnecessary.
>
> The following Coccinelle semantic patch was used for making the change:
>
> @@
> expression E;
> statement S;
> @@
>
> E = \(alloc_bootmem\|alloc_bootmem_low\|alloc_bootmem_pages\|alloc_bootmem_low_pages\)(...)
> ... when != E
> - BUG_ON (E == NULL);
>
> @@
> expression E,E1;
> @@
>
> E = \(alloc_bootmem\|alloc_bootmem_low\|alloc_bootmem_pages\|alloc_bootmem_low_pages\)(...)
> ... when != E
> - memset(E,0,E1);
>
> Signed-off-by: Himangi Saraogi <himangi774@xxxxxxxxx>
> Acked-by: Julia Lawall <julia.lawall@xxxxxxx>

Acked-by: David Rientjes <rientjes@xxxxxxxxxx>

Many callers of alloc_bootmem() do not check for the return value because
of this, there's no fallback available at this part in bootstrap so
there's nothing else that can be done.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/