From patchwork Wed Nov 21 12:28: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: 10692523 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 859FD13AD for ; Wed, 21 Nov 2018 12:34:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 728D2293BB for ; Wed, 21 Nov 2018 12:34:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 665142BB2B; Wed, 21 Nov 2018 12:34:12 +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 1AE22293BB for ; Wed, 21 Nov 2018 12:34:11 +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=os8eddloE1DLf9j2vCrx3qT+zLUt0dZor+et6Vb71M0=; b=o+J y1+ANtnZvhRH7feRxvAWaAOcK/8Ig7LpSzC/lLLhj04A1WmnezcBpDkJhR5BbyEtTRldgKnXtW9vm Brl/o8SykSKrIf914QjqwWtUFQrTODEnPCzJ/z5GGnCEpH2RdN/S2yfsFQ4QlOtwER7/pjviT7SA7 7GFe5XB465hFC3MkayPNH1kr+nBRw/2ThcDzzArosaHipVJkE3/kDrXOTEXd4A2lZvPO1cIWdIaKF wiYUQcoZprjhabgLUvzQuxAR55hTqZivAu8f9K2arR6esOQmARgjshS49UWxXkZqXFCOBj6ArwbO2 BgvvSQZ+N7+BuLtjnX2463Vk4Bvq61w==; 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 1gPRhn-00046H-0y; Wed, 21 Nov 2018 12:34:07 +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 1gPRhk-000413-0V for linux-arm-kernel@lists.infradead.org; Wed, 21 Nov 2018 12:34:05 +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 wALCVUk8029987; Wed, 21 Nov 2018 13:31:30 +0100 From: Nicholas Mc Guire To: Michael Turquette Subject: [PATCH V2] clk: zynq: do not allow kmalloc failure Date: Wed, 21 Nov 2018 13:28:30 +0100 Message-Id: <1542803310-32673-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_043404_353691_CD11CB9A X-CRM114-Status: GOOD ( 11.79 ) 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 Fixes: 0ee52b157b8e ("clk: zynq: Add clock controller driver") Acked-by: Michal Simek --- V2: dropped leading spaces from commit message and moved the compile/tool info out of git history on request of Michal Simek - thanks ! 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) 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;