Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp640096rwb; Thu, 8 Dec 2022 00:38:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf4TKAtEb2xBXXck1coJa/ZaD4iVlQqCzXPLhbKs1ssynw5ImdVtD1ABsvf5CV57OGOOImDR X-Received: by 2002:a17:906:2404:b0:7ad:d411:30af with SMTP id z4-20020a170906240400b007add41130afmr35882290eja.636.1670488691645; Thu, 08 Dec 2022 00:38:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670488691; cv=none; d=google.com; s=arc-20160816; b=o5w5W0riNKcOwCku6NAdwsrWc4PXzFkDPRLYGHnkAsYOZPK0YD/bRwzzH6BbGSB7VY zbgZHNBXkrEekJeEOh6CRqikYKGElZVba8LNVdhKJUmiZsp16VvqL01qr9reSH0WJfPz gYB9xQgLpTgQGyn1zo3FZKMbFywOr/i4PrVpLnKKqLaa/6ckL6xhl+4pxTlU9Ct8JpLJ +gmr4it4JjDo3bal2aq+53UMUw9r3zp00fR9Zu+ssVnesI/nY57A+Axeh9//orqdAZzS u2YEZcw+tQpHFmYyiE0prPvhcEtYfxHtDyBeag94UTM/44ecLVnKbGKM58dLXeA4oCwQ vjAQ== 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:references:in-reply-to:user-agent:subject:cc:to:from :date:dkim-signature; bh=3wD/7QnsJQOArzMBiZwxJmKpNjdV/v9vGzP4bPaqNRE=; b=J+UdJuqjCNUOn4eq9UbRGW464WbGt5AJKgh4cAwjvsbZcuO0BmUk2HYt8KjEygv58i tYhKshB0mwKIi3ZzfOpKVnWYagQ8OQTZFrrjg+BiwXV9CrqZH+VPO12ukCoNUHyMR2/j b0RoYO1U+5L7m+wdplN7odKCD9a8j+rABq345yBqkWZ+QrNY3RBYJzIbfYIEOgUPpu9Y wjFbd/3/tiTWQylh79Lzdbg1hagQn3gZ3g55rskjMIC2TZl/inKKlKFCEWr55OznI294 QYEWPagjclPIJ0jnwwruakMCWqWdD47sY8HQhBwVmusjydT8WJqjipfXlGv/SHsi/Gqo bqow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RtrLgqSz; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g10-20020a056402090a00b0045cea9cf231si6697435edz.566.2022.12.08.00.37.53; Thu, 08 Dec 2022 00:38:11 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RtrLgqSz; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229724AbiLHILX (ORCPT + 73 others); Thu, 8 Dec 2022 03:11:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229586AbiLHILW (ORCPT ); Thu, 8 Dec 2022 03:11:22 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B07F55A97; Thu, 8 Dec 2022 00:11:21 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1E9AF61DDC; Thu, 8 Dec 2022 08:11:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC8C0C433D6; Thu, 8 Dec 2022 08:11:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670487080; bh=NdFVTBJpV5FMMzSdVcQDTqogNFQJNtLtSeWiycnqC6E=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=RtrLgqSzZLoWB69bmDOS3Y7k4ID1eB5oGbP+XEwrI1eiBIxQ1wBbk7VMf9VrVerlK I4wa6hWCiREHloeUryFLhcSvLUE6bOloEypzb93wIcq11AJReAGYj+V06L1hHo1b1B S7cpuC2AQv4EleioeAoVJ2XAyIlXc3pL014wddaexDi2PEpfI4BLCpsf0w677cRY0D pSZB8f8pNIeWxAotXGpBMrG5Gx/8N7Tqu6RSNGdGyg3PMA/yhfiarE+IivfTXjm1YN X1Q4/dTX5jwk3ECOrjpw8KMMj0ZW23dIV1dQerNtYvvLXY3h9MFsqPuNda5OmoZgYo XolFDFK5GwU2Q== Date: Thu, 08 Dec 2022 09:11:16 +0100 From: Conor Dooley To: Jiasheng Jiang , 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 Subject: Re: [PATCH] clk: microchip: Add check for devm_kzalloc User-Agent: K-9 Mail for Android In-Reply-To: <20221208074025.29015-1-jiasheng@iscas.ac.cn> References: <20221208074025.29015-1-jiasheng@iscas.ac.cn> Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 On 8 December 2022 08:40:25 GMT+01:00, Jiasheng Jiang wrote: >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" =2E > >Fixes: d39fb172760e ("clk: microchip: add PolarFire SoC fabric clock supp= ort") >Signed-off-by: Jiasheng Jiang Someone already sent this patch, but thanks=2E >--- > drivers/clk/microchip/clk-mpfs-ccc=2Ec | 6 ++++++ > 1 file changed, 6 insertions(+) > >diff --git a/drivers/clk/microchip/clk-mpfs-ccc=2Ec b/drivers/clk/microch= ip/clk-mpfs-ccc=2Ec >index 7be028dced63=2E=2E32aae880a14f 100644 >--- a/drivers/clk/microchip/clk-mpfs-ccc=2Ec >+++ b/drivers/clk/microchip/clk-mpfs-ccc=2Ec >@@ -166,6 +166,9 @@ static int mpfs_ccc_register_outputs(struct device *d= ev, 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=2Ehw=2Einit =3D CLK_HW_INIT_HW(name, &parent->hw, &clk= _divider_ops, 0); > out_hw->divider=2Ereg =3D 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 =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;