Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp3772228ybn; Fri, 27 Sep 2019 11:07:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWAIG9KI2N1amc7o+DgxX4avYeGii4x72EHs/VXcQa6jmvyT3UMsGvfJ0rWb1Si/O2HPfK X-Received: by 2002:a05:6402:1251:: with SMTP id l17mr6086920edw.270.1569607630988; Fri, 27 Sep 2019 11:07:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569607630; cv=none; d=google.com; s=arc-20160816; b=gsusWlcLSh8R9fObOk+qv3xzW0VM4ZUTSydOGc806JlnLg1yrKdeS4U+GLxOgNdcGg 5r8DVcKY7r/ZX8YPTOLG9i8VQRpHAmP8bdKFsi1YQmo936p94eHcpCCjm9CzqZR24bBi atxaVnFJzZ2HJ71M7CK99zyySHoNsQGKwWpus4YGgbBS+TJFTDG26EDUktTMi4YgQ4yp LY9+pyrwr5FmVfrcnFJ6PBPmBbbryOk4+3ootkG6GH0VNWOzM9z5DxYxBGKhYd8dQRRt FfQDNLjuFmAEfqaAAfjB73KD+dV3tcRfVhKJlJM+NkRWog8fLDXJOUICL4hE/Yhuoaqf j7IQ== 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=/gqjQlstDkgNd63CyBHjcIpnLkY269eB3faXqe7gLk8=; b=V8YY2EIzuXz7ewCL84UVFsIpb5GcWxAsusVQvS40O93RQp6ZuPhqNNW9x6naxbOY7V o6WuutVwKZi0ROHSdikkRF3lEzIuMSvWuz1ZI6uTEYfAy1lt2VkRWKBoXsro2cT3t5IY a3m8cOy153kNrvtkTbin30wKV/iMrpxFmozMYYD/TN3nq8jrleuVXfGShT+UEpCx+9L6 Ev20fwG2MJpAXJMLOBEhvYkjnTc0OSeLdD6WH7NJCRBxN1JpwkdHpZdWqcmL3ttzR3nU IiKxFlqzj2rmaIgPfRWkeagBLmwSDbwNpQCV8vFOEIScwAq/L04W+FRrnnzX17jbwtZS OFng== 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 dt14si3192462ejb.168.2019.09.27.11.06.45; Fri, 27 Sep 2019 11:07:10 -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 S1727289AbfI0SGa (ORCPT + 99 others); Fri, 27 Sep 2019 14:06:30 -0400 Received: from 17.mo6.mail-out.ovh.net ([46.105.36.150]:42475 "EHLO 17.mo6.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726676AbfI0SGa (ORCPT ); Fri, 27 Sep 2019 14:06:30 -0400 Received: from player762.ha.ovh.net (unknown [10.108.57.49]) by mo6.mail-out.ovh.net (Postfix) with ESMTP id A150A1E308E for ; Fri, 27 Sep 2019 20:06:28 +0200 (CEST) Received: from sk2.org (unknown [109.190.253.11]) (Authenticated sender: steve@sk2.org) by player762.ha.ovh.net (Postfix) with ESMTPSA id 0B6C1A546CCA; Fri, 27 Sep 2019 18:06:16 +0000 (UTC) From: Stephen Kitt To: Tero Kristo , Michael Turquette , Stephen Boyd , linux-omap@vger.kernel.org, linux-clk@vger.kernel.org, Tony Lindgren Cc: linux-kernel@vger.kernel.org, Stephen Kitt Subject: [PATCH v2] clk/ti/adpll: allocate room for terminating null Date: Fri, 27 Sep 2019 20:05:59 +0200 Message-Id: <20190927180559.18162-1-steve@sk2.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 5738711825322888647 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrfeeigdduudelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm 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 ka_sprintf to avoid overflowing. Signed-off-by: Stephen Kitt --- drivers/clk/ti/adpll.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/clk/ti/adpll.c b/drivers/clk/ti/adpll.c index fdfb90058504..021cf9e2b4db 100644 --- a/drivers/clk/ti/adpll.c +++ b/drivers/clk/ti/adpll.c @@ -195,14 +195,8 @@ static const char *ti_adpll_clk_get_name(struct ti_adpll_data *d, 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.%s.%s", + d->pa, base_name, postfix); } return name; -- 2.20.1