From patchwork Wed Nov 21 10:16:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Mc Guire X-Patchwork-Id: 10692343 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ACA801869 for ; Wed, 21 Nov 2018 10:21:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9970B2B8A8 for ; Wed, 21 Nov 2018 10:21:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D0392B8F6; Wed, 21 Nov 2018 10:21:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2A5F22B8A8 for ; Wed, 21 Nov 2018 10:21:54 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=OfgtnhBGY6GgaAGTYap7eJLVjO667hhvxL63tj0gXDs=; b=M3q bqTlOLtBUq6BuzJ+jft6rFtby8HO014+oPH/8gDhaz4MAn6RsCbrt24tlROttmVddzqEVbPsmOl3e QSirEJ9LkLzlsQdaa92EeSUZkjyldBWmD+MAva3tpPiMc21iCC3EnAmWhQU3iCIDqypoeHdAhHCMc dFUd1Rgg7lNXseRtuOpRgXatJJ+rgH62jNwdOpfcyOAEWhh/0wlsiRIsQrJhi8NUMyKDAc/MCMuly 8orUEnqMijtDW7qYyQzYddNgJIMi/yc4KTW6/N9Ig6coUjsb2X9wwkdP+D9U8rrqgSLDVwAx93Q1H O+yjOeekp61pQEUrStoTpAheFJqiMSA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gPPdp-0006nw-LC; Wed, 21 Nov 2018 10:21:53 +0000 Received: from www.osadl.org ([62.245.132.105]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gPPdm-0006cM-0f for linux-arm-kernel@lists.infradead.org; Wed, 21 Nov 2018 10:21:52 +0000 Received: from debian01.hofrr.at (178.115.242.59.static.drei.at [178.115.242.59]) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id wALAJNgv014644; Wed, 21 Nov 2018 11:19:24 +0100 From: Nicholas Mc Guire To: Michael Turquette Subject: [PATCH] clk: zynq: do not allow kmalloc failure Date: Wed, 21 Nov 2018 11:16:30 +0100 Message-Id: <1542795390-16221-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181121_022150_391404_F1B427C3 X-CRM114-Status: GOOD ( 11.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rob Herring , Stephen Boyd , linux-kernel@vger.kernel.org, Michal Simek , Nicholas Mc Guire , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The kmalloc here is small (< 16 bytes) and occurs during initialization during system startup here (can not be built as module) thus if this kmalloc failed it is an indication of something more serious going on and it is fine to hang the system here rather than cause some harder to understand error by dereferencing NULL. Explicitly checking would not make that much sense here as the only possible reaction would be would BUG() here anyway. Signed-off-by: Nicholas Mc Guire Problem located with experimental coccinelle script Patch was compile tested with: multi_v7_defconfig (implies CONFIG_ARCH_ZYNQ=y) Patch is against 4.20-rc3 (localversion-next is next-20181121) Acked-by: Michal Simek --- drivers/clk/zynq/clkc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/zynq/clkc.c b/drivers/clk/zynq/clkc.c index d7b53ac..014d4a4 100644 --- a/drivers/clk/zynq/clkc.c +++ b/drivers/clk/zynq/clkc.c @@ -440,7 +440,7 @@ static void __init zynq_clk_setup(struct device_node *np) SLCR_GEM1_CLK_CTRL, 0, 0, &gem1clk_lock); tmp = strlen("mio_clk_00x"); - clk_name = kmalloc(tmp, GFP_KERNEL); + clk_name = kmalloc(tmp, GFP_KERNEL | __GFP_NOFAIL); for (i = 0; i < NUM_MIO_PINS; i++) { int idx;