Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp586538rwb; Wed, 7 Dec 2022 23:44:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf4wM2GxSTrOlCUQo8zd/nD7mEgZBiWdkH93Aha9/E9cT+bpTGCsBP7YavrlxQhANlrx6y7j X-Received: by 2002:aa7:c144:0:b0:46b:badf:882c with SMTP id r4-20020aa7c144000000b0046bbadf882cmr29437180edp.233.1670485460056; Wed, 07 Dec 2022 23:44:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670485460; cv=none; d=google.com; s=arc-20160816; b=nuAg4xonGILIts9/+q/t4P7wHSO0vAAV2aohagmRyMxmYzAhZ710/LIOxYL1Fti6bL xcW05CESh/Y16/81fekqSNEENS09n26VNBubeWI9He9o71Zg+CoXVBV8oOJ0JR81fDtB 6sQKd3eYOZCaLErxMb9WwsdBTnrUU+HR7pa/ewRcRXoj8q+AON799NWMVw7ASldKU87K kw7PYYxG1oviE5ZYkyXsKv7mm0iCSnUfsQn4sT7GO17dPQV/2dbVJkz2QkZV1XSfWMYj Ja62Fm0B6P+hlG0bW5qrBS3Td+gU/F+axD4QnPKh4PjE+bUscnZaT6kdnJXwlgsK3Gsh m5Iw== 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=rVQfx+cpRk2VsftQd+pbeffcKGEC4pSpzUggsB2ladU=; b=W4WkZiwwOiMBspYY5KwDmFDvXS9Db3ZfgNB9P5SN1BRzUzm9aUqWJ3TRyKU5JcWrI2 kMCkp/AJjrn2jG4Lls/n06DWBzn2NELLT3UJq8NueDkijVirid7x49hlG5YWjZSfWHIn BZnK/zd/KUvA2O47vqNwcjsgzrokJm+atRiS+wnfh5w98HudIPFJbtk618Ldlutm+bTK gVtsAko4ujmeHyHgp4seM9h6H/LAPLsyMyv4Ad+XP6i2JWuKw0AAgKBeMAh85IO3sSNk EUSbabRqPEOdi37YIffqUf5y76DbLwfvXgDKpfrgzriTExNwad1y/79nkzQLeTRj30vN pT/w== 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 x12-20020a05640226cc00b00460faf7d2a3si7151565edd.277.2022.12.07.23.44.01; Wed, 07 Dec 2022 23:44:20 -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 S229724AbiLHHkg (ORCPT + 74 others); 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: 8bit 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/ X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS 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 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 support") 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/clk-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 = &out_hws[i]; char *name = devm_kzalloc(dev, 23, GFP_KERNEL); + if (!name) + return -ENOMEM; + snprintf(name, 23, "%s_out%u", parent->name, i); out_hw->divider.hw.init = CLK_HW_INIT_HW(name, &parent->hw, &clk_divider_ops, 0); out_hw->divider.reg = data->pll_base[i / MPFS_CCC_OUTPUTS_PER_PLL] + @@ -200,6 +203,9 @@ static int mpfs_ccc_register_plls(struct device *dev, struct mpfs_ccc_pll_hw_clo struct mpfs_ccc_pll_hw_clock *pll_hw = &pll_hws[i]; char *name = devm_kzalloc(dev, 18, GFP_KERNEL); + if (!name) + return -ENOMEM; + pll_hw->base = data->pll_base[i]; snprintf(name, 18, "ccc%s_pll%u", strchrnul(dev->of_node->full_name, '@'), i); pll_hw->name = (const char *)name; -- 2.25.1