Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp3586097ybn; Fri, 27 Sep 2019 08:25:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwKSe8vNeQPtj4Bvq6VBXzglZfTMKq6Ej9Hn58QIPSt/rQVe1lhqV5naRqJCsiAtz3JH+r X-Received: by 2002:aa7:d38e:: with SMTP id x14mr5349913edq.102.1569597952382; Fri, 27 Sep 2019 08:25:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569597952; cv=none; d=google.com; s=arc-20160816; b=sHX273LrCpQOPVbZy66k86Dt3opVDa5ZuGxPC3+JjIcQlK2oXbuVW/qH7dKx8JtdEO hQV9eiLkH+P6NnX7dgoobAKUAkdFpYKLGaso7rXO65Z71zwI1v1UEU7LNrBl9Kq56eX6 t6xr4ay/vHnt+6SkodpCb73A/MxIbdOeMiaD5wiPE77ScyqBoNywdJKbBh0BjUEoe8lK QjJSQJwyPaVkfwU4OBghGGrm8CA+rkrhCWd4E7jZS6HQWZC587KVY13ySI9r4cNkbzq8 q9hI/QxsQcWz+6XKmL+KuEkEW+zHc6QMnQS+zFTp79lSJnxklgENiQWuKUaeb2Zxgh4J IQiw== 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=NOY389Bkc0WrmjFfySAomw5hF7nVI1yTB3vc196Vz2U=; b=tUJuNubing/4iNPexkYbROFCum7/8hDyig1/KZt91LQOqzm8LQjM8YcEuHAc8X5eaA F+MShhbPG6t2+nNmEs1wJKEb9xYff63IHkH+ovqZ7Ke+lpF3FgmSWOHjs395PUoC8ECM 8We93tueE9VqsSXUZxJkbClON6pKBWabuw09WJ76Q0Iww7+QvO32ntVW2QcUAYic0Bba xPl1dhX9XtowHsIqmi3wwXqLBNg/cRl8JMayy5iNm0Gyc3O0P27gbrI32rLY+Yl+mMCF eJl1WRRld/MEKUnAq4V0127vPPCnW5moDc3BbSmwDerdgMP7mDh7d3G01zQNy8rlg4N4 Sx2A== 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 c21si2912034ejx.295.2019.09.27.08.25.26; Fri, 27 Sep 2019 08:25:52 -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 S1727447AbfI0PXT (ORCPT + 99 others); Fri, 27 Sep 2019 11:23:19 -0400 Received: from muru.com ([72.249.23.125]:34640 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727140AbfI0PXT (ORCPT ); Fri, 27 Sep 2019 11:23:19 -0400 Received: from atomide.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTPS id C37D88022; Fri, 27 Sep 2019 15:23:50 +0000 (UTC) Date: Fri, 27 Sep 2019 08:23:15 -0700 From: Tony Lindgren To: Stephen Kitt Cc: Tero Kristo , Michael Turquette , Stephen Boyd , linux-omap@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] clk/ti/adpll: allocate room for terminating null Message-ID: <20190927152315.GE5610@atomide.com> References: <20190927145737.7832-1-steve@sk2.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190927145737.7832-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 [190927 15:13]: > The buffer allocated in ti_adpll_clk_get_name doesn't account for the > terminating null. This patch adds the extra byte, and switches to > snprintf to avoid overflowing. > > Signed-off-by: Stephen Kitt > --- > drivers/clk/ti/adpll.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/clk/ti/adpll.c b/drivers/clk/ti/adpll.c > index fdfb90058504..27933c4e8a27 100644 > --- a/drivers/clk/ti/adpll.c > +++ b/drivers/clk/ti/adpll.c > @@ -196,12 +196,13 @@ static const char *ti_adpll_clk_get_name(struct ti_adpll_data *d, > } else { > const char *base_name = "adpll"; > char *buf; > + size_t size = 8 + 1 + strlen(base_name) + 1 + > + strlen(postfix) + 1; > > - buf = devm_kzalloc(d->dev, 8 + 1 + strlen(base_name) + 1 + > - strlen(postfix), GFP_KERNEL); > + buf = devm_kzalloc(d->dev, size, GFP_KERNEL); > if (!buf) > return NULL; > - sprintf(buf, "%08lx.%s.%s", d->pa, base_name, postfix); > + snprintf(buf, size, "%08lx.%s.%s", d->pa, base_name, postfix); > name = buf; > } > Thanks for catching this. Maybe just use devm_kasprintf() here? Regards, Tony