Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751057AbaGUW4x (ORCPT ); Mon, 21 Jul 2014 18:56:53 -0400 Received: from mail-ig0-f175.google.com ([209.85.213.175]:59482 "EHLO mail-ig0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750800AbaGUW4v (ORCPT ); Mon, 21 Jul 2014 18:56:51 -0400 Date: Mon, 21 Jul 2014 15:56:48 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Himangi Saraogi cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, Julia Lawall Subject: Re: [PATCH] x86, olpc: Eliminate BUG_ON and memset after alloc_bootmem In-Reply-To: <20140719113637.GA23621@himangi-Dell> Message-ID: References: <20140719113637.GA23621@himangi-Dell> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Acked-by: Julia Lawall Acked-by: David Rientjes 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/