Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2048728ybg; Sat, 19 Oct 2019 07:24:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyLaaOznPLgYIL0OiN5g9A9ZIOhCYUnquuHweVKWDoMyHnq7whufhEOESQZhJ5ZG28kHxiB X-Received: by 2002:a05:6402:1a33:: with SMTP id be19mr15247864edb.197.1571495054581; Sat, 19 Oct 2019 07:24:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571495054; cv=none; d=google.com; s=arc-20160816; b=lJnqoeFIRQ60vBn1kwEygS2jfQ2OCK4QrCVQWKq7q1EWjiyxTYajURKnrDuLyZhnYo qwXvRaIkhFKD/s2IrArFgGEdS3DOIfgMpNLlGBREg+8IYDU8LpXCqDXD7WDohs7cqMMC xFGuD3NqRIRagsCaQ2TTVKuee76SsOAcbj/fjSRRIyTzp5WpQstL9tEc+0ocZ1r6EVay ycIzMBNkjIEBvjixgodrHMWUfxNfInUeC6HQMOc8SOBgvJoik7f7OtzrqpPbDSyFyO5M wJj9TgFRx7C3MOIZEmmJIghAetYYpIoVrZxIwqjGnczVHD0EAqBAwPf2pmdF/CIzBuuo 5lVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=vLEsMYGTdIS4F0qm1FX6iTaBWaR+4AmyBHiqDTDeVj8=; b=sIQRynYxbc7Z1r+UL89UT+qfx4H+4buxc3P1f4OLv3KG4Z23EUV8NZFUYbzy8iFkcS 09Oi+xhLGtd/zzWoNG8fDYiE6pfIhRTdGjLQfrz1RDrnK+iGnOgcKzH6e3PyPiKckIJV PCtcdXolytjVRMIeUAMq3rlQGfKZNUcU05UYy2SpgBQWcwwGDvKUS85SrW6i76wLE+Hn POIdpkKGV1Ec7RQPgz/WvPh37803BjG/7mvSofy7KJgJ2WvYqa79uCkK8K3D7dH0f0Tf ufkxmySA11eGXvzoOMQNi7+9vhip/f2sJLi+g7Jn0aPSCRpwCUseFAF9qGWuXk2co5dU rIAQ== 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 d19si5735190edv.287.2019.10.19.07.23.48; Sat, 19 Oct 2019 07:24:14 -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 S1725938AbfJSOXb (ORCPT + 99 others); Sat, 19 Oct 2019 10:23:31 -0400 Received: from 2.mo68.mail-out.ovh.net ([46.105.52.162]:43604 "EHLO 2.mo68.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725911AbfJSOXa (ORCPT ); Sat, 19 Oct 2019 10:23:30 -0400 Received: from player714.ha.ovh.net (unknown [10.108.42.196]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id EF17B145F3D for ; Sat, 19 Oct 2019 16:07:01 +0200 (CEST) Received: from sk2.org (gw.sk2.org [88.186.243.14]) (Authenticated sender: steve@sk2.org) by player714.ha.ovh.net (Postfix) with ESMTPSA id BA673B1A3FB1; Sat, 19 Oct 2019 14:06:51 +0000 (UTC) From: Stephen Kitt To: Stephen Boyd Cc: Michael Turquette , Tero Kristo , Tony Lindgren , linux-clk@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, Stephen Kitt Subject: [PATCH v3] clk/ti/adpll: allocate room for terminating null Date: Sat, 19 Oct 2019 16:06:34 +0200 Message-Id: <20191019140634.15596-1-steve@sk2.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191019155441.2b1b349f@heffalump.sk2.org> References: <20191019155441.2b1b349f@heffalump.sk2.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 1766818431945362904 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrkedugddtiecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. --- 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