From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heiko Carstens Subject: Re: [PATCH 19/21] treewide: add checks for the return value of memblock_alloc*() Date: Fri, 18 Jan 2019 09:43:02 +0100 Message-ID: <20190118084302.GA4160@osiris> References: <1547646261-32535-1-git-send-email-rppt@linux.ibm.com> <1547646261-32535-20-git-send-email-rppt@linux.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Message-Id:In-Reply-To:MIME-Version: References:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZLbLAZ24QjTFYv9s72xTim+rw7rrwaP6PX1ZjCQXPD8=; b=dYr62yXi/EtofE eFCbt9Oh2RF7QtliyBzGtmk0B2vzmkEO4zEpXkyRZvvzR+ude1MpuSeObF/agT2uJkn2EZ2SXx6Gg 2npKbQMlrVJY+g2kj8Vc2XKs1ocTzejR6y1qONFU/o9UTmgP3YQiFOUfpVoo2QlVETfuJW0k5oNMM 9lFpr6YOo6q9U7MKCcabqRKHAWZLsCoK0jsgoF8upYagylqWu9GzQoipVKN5BK4JC4ojbzjqaU0pY 9Fl4C9XsGgP/p9FANDBri8FNzMOUqct5Tuytg40+t0ZntZc9MegJhIvcsu0b88VAfV4NbUn4ut4JS BHKnDmGQks3N6afhj5mQ==; In-Reply-To: <1547646261-32535-20-git-send-email-rppt@linux.ibm.com> Content-Disposition: inline List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+gla-linux-snps-arc=m.gmane.org@lists.infradead.org To: Mike Rapoport Cc: Rich Felker , linux-ia64@vger.kernel.org, devicetree@vger.kernel.org, Catalin Marinas , x86@kernel.org, linux-mips@vger.kernel.org, Max Filippov , Guo Ren , sparclinux@vger.kernel.org, Christoph Hellwig , linux-s390@vger.kernel.org, linux-c6x-dev@linux-c6x.org, Yoshinori Sato , Richard Weinberger , linux-sh@vger.kernel.org, Russell King , kasan-dev@googlegroups.com, Geert Uytterhoeven , Mark Salter , Dennis Zhou , Matt Turner , linux-snps-arc@lists.infradead.org, uclinux-h8-devel@lists.sourceforge.jp, Petr Mladek , linux-xtensa@linux-xtensa.org, linux-alpha@vger.kernel.org, linux-um@lists.infradead.org, linux-m68k@li 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 ... > diff --git a/arch/s390/numa/toptree.c b/arch/s390/numa/toptree.c > index 71a608c..0118c77 100644 > --- a/arch/s390/numa/toptree.c > +++ b/arch/s390/numa/toptree.c > @@ -31,10 +31,14 @@ struct toptree __ref *toptree_alloc(int level, int id) > { > struct toptree *res; > > - if (slab_is_available()) > + if (slab_is_available()) { > res = kzalloc(sizeof(*res), GFP_KERNEL); > - else > + } else { > res = memblock_alloc(sizeof(*res), 8); > + if (!res) > + panic("%s: Failed to allocate %zu bytes align=0x%x\n", > + __func__, sizeof(*res), 8); > + } > if (!res) > return res; Please remove this hunk, since the code _should_ be able to handle allocation failures anyway (see end of quoted code). Otherwise for the s390 bits: Acked-by: Heiko Carstens