Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp3788525ybn; Fri, 27 Sep 2019 11:21:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqzRJNlpsJVIpXPv1lDM9NIVdkO9EQFu+fCHLIhH/2I6o/IsxtVfoJyM1+mkvlZDKxqH4Az+ X-Received: by 2002:a17:906:3281:: with SMTP id 1mr9058890ejw.181.1569608499114; Fri, 27 Sep 2019 11:21:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569608499; cv=none; d=google.com; s=arc-20160816; b=SL5KvNX8jEaohynW+ADgkhY1kQwoqFSsNrg+DE9Dixpftq66LYbQ66n6jEdD/9WJW7 aD5PTz24Ojl2MhS+GHSXsAJf+oSyDUPjwa+cjJdt4rWw008SezGMwkjgEEkvfuhElBsU VrvNB7cM9bhoOtbCZ5urA6ysleqw437wt588h50rHpr77thwJuBu1MnqgKxYEeixuQjw IDuKUyfxKIWNEtJ7aoHQ6daTK0NDekigGZEX/9l4VNuwBu1P9SoL8Z63DDWjDBlJRdkF qDTPO39w/+lBffekkkS2fLZPDro7VYWOX4wspRXDiNllDe8lu2PZFowy5oIJpkrecMHC ia1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version; bh=U3hL4dNCkblUXiNpqLjOFCb3qAoqJViDEoz/yxsNKmo=; b=Vryvjp0Q0zQ8xAGUtUMqOextbBMGKQcclZFz9GsAZ+qFxXDH3pnD64ZC5IbktQ2Nqe izA+AXdMg9wkrel8ruwXU+OeBb+/WN9n4jzOyk9vkdA9iYNvUdW00sscXExp30B4f6rn Z/C9akP9Yo/wUuPZsCCpZ9Sy6KNtw+ENu3Wly+bJMl9J9pXxmcSfCIFB5pxABC6bbIJU +RPjt2xfznYJ/zrjX0lRbj5wKHSKMfbR1AArAH8UWUCTZKnQRWTgA83lSNUM0wCE5L15 b43wWDCml3zwDAUMIiVU4IXS+K9qWVZN0eBrAi59P7dnddBUzylBxjV/+wGF5o+H+KCd UL2w== 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 p43si2059737edc.368.2019.09.27.11.21.13; Fri, 27 Sep 2019 11:21:39 -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 S1728147AbfI0SUB (ORCPT + 99 others); Fri, 27 Sep 2019 14:20:01 -0400 Received: from 9.mo179.mail-out.ovh.net ([46.105.76.148]:45036 "EHLO 9.mo179.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728117AbfI0SUA (ORCPT ); Fri, 27 Sep 2019 14:20:00 -0400 X-Greylist: delayed 11117 seconds by postgrey-1.27 at vger.kernel.org; Fri, 27 Sep 2019 14:20:00 EDT Received: from player691.ha.ovh.net (unknown [10.108.54.97]) by mo179.mail-out.ovh.net (Postfix) with ESMTP id 280C51423FD for ; Fri, 27 Sep 2019 20:00:29 +0200 (CEST) Received: from RCM-web9.webmail.mail.ovh.net (unknown [109.190.253.11]) (Authenticated sender: steve@sk2.org) by player691.ha.ovh.net (Postfix) with ESMTPSA id 9F609A6A320C; Fri, 27 Sep 2019 18:00:21 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Fri, 27 Sep 2019 20:00:21 +0200 From: Stephen Kitt To: Tony Lindgren 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 In-Reply-To: <20190927152315.GE5610@atomide.com> References: <20190927145737.7832-1-steve@sk2.org> <20190927152315.GE5610@atomide.com> Message-ID: X-Sender: steve@sk2.org User-Agent: Roundcube Webmail/1.3.10 X-Originating-IP: 109.190.253.11 X-Webmail-UserID: steve@sk2.org X-Ovh-Tracer-Id: 5637380835038678298 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrfeeigdduudekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 27/09/2019 17:23, Tony Lindgren a écrit : > * 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? Ah yes, that would be much better! V2 coming up, thanks for the suggestion. Regards, Stephen