Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp9911018rwl; Wed, 11 Jan 2023 11:42:22 -0800 (PST) X-Google-Smtp-Source: AMrXdXuXK5/0+VCA+0kDmU4pPzuG3eaT8OZrq+iP2i46WwV9fnxrF8Inn637z3gLpky2I61hJ07C X-Received: by 2002:a17:906:7046:b0:7ae:8194:7e06 with SMTP id r6-20020a170906704600b007ae81947e06mr65927672ejj.56.1673466142645; Wed, 11 Jan 2023 11:42:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673466142; cv=none; d=google.com; s=arc-20160816; b=pwj5pMyOZNIO9uigeaN/wC6604OMAZ7p06YSXPRX0CIAZFppo7mETlVivK8Sn9tmYj 4p+MLCYw62SxzHjOmrE1wVCGNUvVS+P8m5YWvh91yswOaaXhfhT3QExUn3Ody6IMWqP2 WpU8laMMJg92GAfIfzTMsgKY0NUojaeJcaDGPj0dMOZjwjyUdnoGErtWv82Z534u85+8 zJzuxhkjMAvj9qo3+k4beKRzwdBMka7f+29eTRu+vTTaIxXCLWpZMed6xeq5E2JZu3Yk JO168V5pYRb/0hcMv9hD3o3a5jdgl+fu+WSNwU9VYxRWNyfZs8KyLJB6CWPkPPw/pU7D pNiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LDyk4JnyJf+q5upvuOxxShpTifge9YoTRIupACn/eMY=; b=R/xSp+jIt5rxFokbywiDwqlvOZe7/6V+6So6Xz19Bk3gukkNC02177MfgdYO6q5Q2U 2CqPkVW11ICt1B83uuIpB5j01NAIYCN6xtjaYkmNE2IBd19fyAGXTwx6TUHqJJMaZjk6 sHfNaO0PG8cjNAEyk5xUDmCVE9CjfVonnkw7yFzYFHW4kbxWFccGhg0UTvLbvpW50Qvx zTuKRIn3eUznCmTIZGjKTMa745BPQuPOdBBw8RZlZxmlpU5PvuLI/uvQvAVOsPWnJSWB VR4/1QgVvYkaVBfumrWd2xH8+y4efiIxYXuUuMWJyswIJ+nJslyaLtRqyt947PxMqk57 yT+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WbbSLfoU; 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 go9-20020a1709070d8900b007c4f78e6104si15596482ejc.408.2023.01.11.11.42.10; Wed, 11 Jan 2023 11:42:22 -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=WbbSLfoU; 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 S234039AbjAKT01 (ORCPT + 51 others); Wed, 11 Jan 2023 14:26:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232477AbjAKT0Y (ORCPT ); Wed, 11 Jan 2023 14:26:24 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 442DCD2DB; Wed, 11 Jan 2023 11:26:23 -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 ams.source.kernel.org (Postfix) with ESMTPS id E7830B81C9B; Wed, 11 Jan 2023 19:26:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB83BC433EF; Wed, 11 Jan 2023 19:26:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673465180; bh=UPbsf7hK6LI/9fYSGa56Uex4aDJWhPnt2DVwE2KC6RA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WbbSLfoUcpHGQq3IgLsSV47Q8RVMXLlQvrEXkd4y7xVA/KKqFq3Euui5gmXaW2GKY Ur5wk62tk+XioMbeTxZ02+mPScA170qbF3pWKUzLWelpxLjUv9hUB9s4sWvAFENE5X Iygsvy9EIJ5CD0xG8jNuSgMipdpFciq+qh795V7eqxz6O1T21gakFdtau6PUwXMLrn ptNO5yTo/B6MvlpiVU51RHq6uYss7NoXjBmusyVLiPSglySevRwzhWRNIDD9n6NloP KvUkC07ek0Xt0bJLlOyNHtj/Z1XVJ8MjaBEMx9xJGbyJZrYqOYlSjSYKi418n0I51O CQfyYFu4I3poA== Date: Wed, 11 Jan 2023 19:26:16 +0000 From: Conor Dooley To: Geert Uytterhoeven , Claudiu.Beznea@microchip.com Cc: Michael Turquette , Stephen Boyd , Claudiu Beznea , Conor Dooley , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] clk: microchip: mpfs-ccc: Use devm_kasprintf() for allocating formatted strings Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="WFNREt5T4zNKwgvA" Content-Disposition: inline In-Reply-To: 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 --WFNREt5T4zNKwgvA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hey Claudiu, Could you pick this one up when you get a chance please? Thanks, Conor. On Tue, Jan 03, 2023 at 05:45:30PM +0100, Geert Uytterhoeven wrote: > In various places, string buffers of a fixed size are allocated, and > filled using snprintf() with the same fixed size, which is error-prone. >=20 > Replace this by calling devm_kasprintf() instead, which always uses the > appropriate size. >=20 > While at it, remove an unneeded intermediate variable, which allows us > to drop a cast as a bonus. >=20 > Signed-off-by: Geert Uytterhoeven > --- > drivers/clk/microchip/clk-mpfs-ccc.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) >=20 > diff --git a/drivers/clk/microchip/clk-mpfs-ccc.c b/drivers/clk/microchip= /clk-mpfs-ccc.c > index 32aae880a14f3b1c..0ddc73e07be42973 100644 > --- a/drivers/clk/microchip/clk-mpfs-ccc.c > +++ b/drivers/clk/microchip/clk-mpfs-ccc.c > @@ -164,12 +164,11 @@ static int mpfs_ccc_register_outputs(struct device = *dev, struct mpfs_ccc_out_hw_ > =20 > for (unsigned int i =3D 0; i < num_clks; i++) { > struct mpfs_ccc_out_hw_clock *out_hw =3D &out_hws[i]; > - char *name =3D devm_kzalloc(dev, 23, GFP_KERNEL); > + char *name =3D devm_kasprintf(dev, GFP_KERNEL, "%s_out%u", parent->nam= e, i); > =20 > if (!name) > return -ENOMEM; > =20 > - snprintf(name, 23, "%s_out%u", parent->name, i); > out_hw->divider.hw.init =3D CLK_HW_INIT_HW(name, &parent->hw, &clk_div= ider_ops, 0); > out_hw->divider.reg =3D data->pll_base[i / MPFS_CCC_OUTPUTS_PER_PLL] + > out_hw->reg_offset; > @@ -201,14 +200,13 @@ static int mpfs_ccc_register_plls(struct device *de= v, struct mpfs_ccc_pll_hw_clo > =20 > for (unsigned int i =3D 0; i < num_clks; i++) { > struct mpfs_ccc_pll_hw_clock *pll_hw =3D &pll_hws[i]; > - char *name =3D devm_kzalloc(dev, 18, GFP_KERNEL); > =20 > - if (!name) > + pll_hw->name =3D devm_kasprintf(dev, GFP_KERNEL, "ccc%s_pll%u", > + strchrnul(dev->of_node->full_name, '@'), i); > + if (!pll_hw->name) > return -ENOMEM; > =20 > 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; > pll_hw->hw.init =3D CLK_HW_INIT_PARENTS_DATA_FIXED_SIZE(pll_hw->name, > pll_hw->parents, > &mpfs_ccc_pll_ops, 0); > --=20 > 2.25.1 >=20 --WFNREt5T4zNKwgvA Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCY78NWAAKCRB4tDGHoIJi 0sD4AP9f2q2+IO9ibu6WIBfOj/1YvSSOh5ixFVvBbHDuYlk+VAD+Mf8Gwx2rEzq1 8JU9u0BU2lvtn3zuQR5/O0UVUQt0AwM= =Bzqk -----END PGP SIGNATURE----- --WFNREt5T4zNKwgvA--