Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4339525ybg; Mon, 21 Oct 2019 07:31:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCcCRcUdsUhTx89ICRNqkIMaL9AOe+hnMuG4ciOJOCuhvAyv2orE55F1HHaBqcwcvo4kKf X-Received: by 2002:aa7:d389:: with SMTP id x9mr25533517edq.33.1571668314409; Mon, 21 Oct 2019 07:31:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571668314; cv=none; d=google.com; s=arc-20160816; b=D/6kG52TBsrzkAmCWRBxtiK9vyMVBN31rg6b0awYEekEmEaapOuClfZXxBJ9mWsIi/ ppHjSe5imO0BS08Am0OpJBFjN1nqOFqndEo3g60ISEzOpqIktDYbCCyDCjueiBQEgJGF 7YiOvo7JpmfUXjJ3RL30FlhBN3aX1erV8TrUAzVWc7+0Gzb37TIeGtSkOFT7IdgdiAn3 IO/VHTpM2XzejGm0quFOd/rdE5xc7vusS0Sel25AFq60vp/A3P81+tASrT0qIzXk2w7a +fJ29i6Qn38d13WiKP/eJ3CQS16mJDmf6ymjGBrzj62Fo8sRWIau8x7Gwa5ZStwbZgek yL5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Gc+ie0vlp+rhMdDKyDr7Pzp5Iltl1ehB6o2OlDq/fmM=; b=cfBD058vvv6DVD4SRMcOtSnDrt1UplFe6GZogSoA2OszYVzltzkItPKvpWRS0thXPn PJnzDHZ6+b+E6EP5RHiAAoTfgY+wh/I12cFv2N6nTwRgSk9I+erY9A9yN5kmnuVaKJha eykzGZVxcY5Hx7hRFp3RHAJ19nXhFJ3MgmX3FjQpzX6utHFfMPdlWHjOUe+NkFXSntAL DdblhS6YM5OQXDSzpEEMKgMdY35Kn5laSezPwDHuPRhUDoYL8KwWC3GmiOl5K5L3tZQr ThiltjZV3/A8BU4kLtBa8NPqnB3/5inIzIL+3sDTb7HD11YjhoJ2AHG8Mts6Y/32XpzT F73w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r14si8779797eju.69.2019.10.21.07.31.29; Mon, 21 Oct 2019 07:31:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728872AbfJUObO (ORCPT + 99 others); Mon, 21 Oct 2019 10:31:14 -0400 Received: from muru.com ([72.249.23.125]:38392 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726977AbfJUObO (ORCPT ); Mon, 21 Oct 2019 10:31:14 -0400 Received: from atomide.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTPS id 2A172810A; Mon, 21 Oct 2019 14:31:48 +0000 (UTC) Date: Mon, 21 Oct 2019 07:31:10 -0700 From: Tony Lindgren To: Stephen Kitt Cc: Stephen Boyd , Michael Turquette , Tero Kristo , linux-clk@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] clk/ti/adpll: allocate room for terminating null Message-ID: <20191021143110.GT5610@atomide.com> References: <20191019155441.2b1b349f@heffalump.sk2.org> <20191019140634.15596-1-steve@sk2.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191019140634.15596-1-steve@sk2.org> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Stephen Kitt [191019 14:07]: > The buffer allocated in ti_adpll_clk_get_name doesn't account for the > terminating null. This patch switches to devm_kasprintf to avoid > overflowing. > > Signed-off-by: Stephen Kitt > --- > Changes since v2: > - Move "adpll" into the format string and drop base_name entirely. > > Changes since v1: > - Use devm_kasprintf instead of manually allocating the target > buffer. Acked-by: Tony Lindgren > --- > drivers/clk/ti/adpll.c | 11 ++--------- > 1 file changed, 2 insertions(+), 9 deletions(-) > > diff --git a/drivers/clk/ti/adpll.c b/drivers/clk/ti/adpll.c > index fdfb90058504..bb2f2836dab2 100644 > --- a/drivers/clk/ti/adpll.c > +++ b/drivers/clk/ti/adpll.c > @@ -194,15 +194,8 @@ static const char *ti_adpll_clk_get_name(struct ti_adpll_data *d, > if (err) > return NULL; > } else { > - const char *base_name = "adpll"; > - char *buf; > - > - buf = devm_kzalloc(d->dev, 8 + 1 + strlen(base_name) + 1 + > - strlen(postfix), GFP_KERNEL); > - if (!buf) > - return NULL; > - sprintf(buf, "%08lx.%s.%s", d->pa, base_name, postfix); > - name = buf; > + name = devm_kasprintf(d->dev, GFP_KERNEL, "%08lx.adpll.%s", > + d->pa, postfix); > } > > return name; > -- > 2.20.1 >