From nobody Thu Sep 18 07:22:41 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 722AEC3A5A7 for ; Thu, 8 Dec 2022 07:40:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229732AbiLHHkg (ORCPT ); Thu, 8 Dec 2022 02:40:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229513AbiLHHkd (ORCPT ); Thu, 8 Dec 2022 02:40:33 -0500 Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D15C546674 for ; Wed, 7 Dec 2022 23:40:31 -0800 (PST) Received: from localhost.localdomain (unknown [124.16.138.125]) by APP-01 (Coremail) with SMTP id qwCowAA3PVnqlJFjsie0BQ--.39882S2; Thu, 08 Dec 2022 15:40:26 +0800 (CST) From: Jiasheng Jiang To: mturquette@baylibre.com, sboyd@kernel.org, claudiu.beznea@microchip.com, conor.dooley@microchip.com Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH] clk: microchip: Add check for devm_kzalloc Date: Thu, 8 Dec 2022 15:40:25 +0800 Message-Id: <20221208074025.29015-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qwCowAA3PVnqlJFjsie0BQ--.39882S2 X-Coremail-Antispam: 1UD129KBjvJXoW7tFW8uw1kWF43GryDJr4xWFg_yoW8XF48pa n5tayYyrsrXr4kW3WIyFWq9F90vF1ktayI9a97u3WkCrn8WrWDJFWxCFyFvFn5u395Gw1a qFs8Ga4rCw1UArJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkv14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26ryj6F1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4j 6r4UJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r xl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj 6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr 0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxkIecxEwVAFwVW8 CwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r 1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij 64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr 0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF 0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUffHUUUUUU= X-Originating-IP: [124.16.138.125] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" As devm_kzalloc may return NULL pointer, the return value should be checked and return error if it fails since NULL is a invalid value of "name" . Fixes: d39fb172760e ("clk: microchip: add PolarFire SoC fabric clock suppor= t") Signed-off-by: Jiasheng Jiang --- drivers/clk/microchip/clk-mpfs-ccc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/clk/microchip/clk-mpfs-ccc.c b/drivers/clk/microchip/c= lk-mpfs-ccc.c index 7be028dced63..32aae880a14f 100644 --- a/drivers/clk/microchip/clk-mpfs-ccc.c +++ b/drivers/clk/microchip/clk-mpfs-ccc.c @@ -166,6 +166,9 @@ static int mpfs_ccc_register_outputs(struct device *dev= , struct mpfs_ccc_out_hw_ struct mpfs_ccc_out_hw_clock *out_hw =3D &out_hws[i]; char *name =3D devm_kzalloc(dev, 23, GFP_KERNEL); =20 + if (!name) + return -ENOMEM; + snprintf(name, 23, "%s_out%u", parent->name, i); out_hw->divider.hw.init =3D CLK_HW_INIT_HW(name, &parent->hw, &clk_divid= er_ops, 0); out_hw->divider.reg =3D data->pll_base[i / MPFS_CCC_OUTPUTS_PER_PLL] + @@ -200,6 +203,9 @@ static int mpfs_ccc_register_plls(struct device *dev, s= truct mpfs_ccc_pll_hw_clo struct mpfs_ccc_pll_hw_clock *pll_hw =3D &pll_hws[i]; char *name =3D devm_kzalloc(dev, 18, GFP_KERNEL); =20 + if (!name) + return -ENOMEM; + pll_hw->base =3D data->pll_base[i]; snprintf(name, 18, "ccc%s_pll%u", strchrnul(dev->of_node->full_name, '@'= ), i); pll_hw->name =3D (const char *)name; --=20 2.25.1