Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1779260pxp; Thu, 10 Mar 2022 12:01:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6yR/qzEQrchb+biCKpIx/DOiMNZ6MvqfAFL1uiFQGinnyrDSeToG1Jo5QJxwEoUinUcP2 X-Received: by 2002:a17:906:c053:b0:6b5:fde8:af2 with SMTP id bm19-20020a170906c05300b006b5fde80af2mr5654938ejb.642.1646942488849; Thu, 10 Mar 2022 12:01:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646942488; cv=none; d=google.com; s=arc-20160816; b=Zh0OuK1Nj1IYjcdomSIChZo61ZvUCt8gIQwPtneOJl+LY0bHd/6Zdbb/pEGd1RRceK y2dYelUBRnCzBg2ONvdiBewJ3ri88mxOl9OgoyQGbkJ2LdMwwd5WWY5s3tNg83MqV4iB W/c2/NKu9hK1E983s6+K8ZFAEEoZuufS40BmhbnPXYF98RvL3sQGNAe6tYUi0rOy4wZr MCm7l6mVx/gr8vblaZO30euD7e666KbCMqtBDEV+fS+1KysVCtHXveYzf3WitRTU+aA1 3SSGG+btkvppuvpysj4NwyX45JydmgbV7DmPIe/BokyPtHmBQ11D7HmII5t3wU4VPhJ0 L0+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=zshxUaJPshSlyHrwqpB6jGWLrF0nFUsfFmrKwITK5QU=; b=UGmr209596rBMLbc9cTJoy3UDonQz1l2T2gzjITFavu8zdi1RmR9UCFdXbet5WNb/N 0YQYhTKAg7qTa/Pg/C+uPh7+lXv4HgTb3ySFdDTsYVW3bPJC7G6sWsp7MppmLut3DslQ D+5Lbr06UirFR2qVbZRshdrk+Q5XlHWUOBvgrtKN8IpggxelXOaggHo4296UlLhaL3Vj Q0Kh2ukEZc0VRs7AsHDB46V3aZgfPvr9g8HH5HO5LFOhkGRAoUIWIHR6iV/bmhFGUhYp 6rXa/dLgOWhosgAqpA+pe0CxI36PQCImqbeb4I5mebVS06tdppJvAbfsAmMwCiskGdNj To+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b6-20020a50ccc6000000b00416306fdc00si3612173edj.618.2022.03.10.12.01.04; Thu, 10 Mar 2022 12:01:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240174AbiCJIEW (ORCPT + 99 others); Thu, 10 Mar 2022 03:04:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231814AbiCJIET (ORCPT ); Thu, 10 Mar 2022 03:04:19 -0500 Received: from cstnet.cn (smtp84.cstnet.cn [159.226.251.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 24DDD48385; Thu, 10 Mar 2022 00:03:17 -0800 (PST) Received: from localhost.localdomain (unknown [124.16.138.126]) by APP-05 (Coremail) with SMTP id zQCowABnVkGysClibGjFAg--.11037S2; Thu, 10 Mar 2022 16:02:59 +0800 (CST) From: Jiasheng Jiang To: abel.vesa@nxp.com, mturquette@baylibre.com, sboyd@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH] clk: imx: Add check for kcalloc Date: Thu, 10 Mar 2022 16:02:57 +0800 Message-Id: <20220310080257.1988412-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: zQCowABnVkGysClibGjFAg--.11037S2 X-Coremail-Antispam: 1UD129KBjvdXoWrury5Jw45GFykAw1UWryxGrg_yoW3Xrg_Ga yrJrn7Grs8tFnayF1UAr1rZr9Yvwn7Zr4xW3WavFy3J3y7Ar17J3yjvws3Xr17GrWj9FZx C34qkrWxCr9xujkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbxkFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_ Gr1UM28EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628v n2kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F4 0E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFyl IxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxV AFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6rW3Jr0E3s1lIxAIcVC2z280aVAFwI0_ Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUb XdbUUUUUU== X-Originating-IP: [124.16.138.126] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As the potential failure of the kcalloc(), it should be better to check it in order to avoid the dereference of the NULL pointer. Fixes: 379c9a24cc23 ("clk: imx: Fix reparenting of UARTs not associated with stdout") Signed-off-by: Jiasheng Jiang --- drivers/clk/imx/clk.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c index 7cc669934253..99249ab361d2 100644 --- a/drivers/clk/imx/clk.c +++ b/drivers/clk/imx/clk.c @@ -173,6 +173,8 @@ void imx_register_uart_clocks(unsigned int clk_count) int i; imx_uart_clocks = kcalloc(clk_count, sizeof(struct clk *), GFP_KERNEL); + if (!imx_uart_clocks) + return; if (!of_stdout) return; -- 2.25.1