Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp3599170ybn; Fri, 27 Sep 2019 08:36:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqz05lSxcjbthSaHp7adtTJ+uLwwmNeaGif48LIpqQnC3KtoHwYNdCScWtdWmK2jbsyvBZr+ X-Received: by 2002:a17:906:ecea:: with SMTP id qt10mr8550513ejb.23.1569598572232; Fri, 27 Sep 2019 08:36:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569598572; cv=none; d=google.com; s=arc-20160816; b=Ui/Wyya9MF+OYXXsgDg/ZM0xL6edjJB4dnrI6ir9MfaLZape1FBuU4gE5BBd69Ti6p EcQd7vwuN9jPVlYk7lvlim/ey8/TtfVUXcOry1b299FEF47sI71zD6o6rBW2yrJO/aX2 Wub7yKi6iVvBmDTxePq+Vl+IwtHW057RAvl3ZJetggyVpnBcMpvZfn5mOB+phTsqIN37 8IUtpndrWDqK8P4Nm9NQ9CM2noAhcgU4vRb1u892CgsYINoqxsOPDACyRW7wD23tCu/4 Y/u+fCodJxrzWukI+gk4cpFfiAFBqWteLERUFWEjqbVnmefcy7idIH2xrNUp9SPHMTGM 4+mg== 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 :message-id:date:subject:cc:to:from; bh=3qX3BA6Zm1lSJiSnKacPlCC/b3II4ZqI4JUqVSj4n/0=; b=NfhmQvBaj4YcfL6mHoWsP/zzojrLD4f4Cabs6XqcZRRBwtAtu5BZnz/cQ+QjQrxXFg 3JjdaCM0YQb/oKzh8M6exARwS8y4BticPO9jCoJh86q2HddAiE61LbUsTQudeE1iTE5R waJi6Xz69e/ohF363a5HX5Jnf69AKM05Dzzv8p+WqHclb1veuEpXJ8/iF0tLtmxFLHTT A80zIQr4XScozpRNsSQz3IfPTMeqGokOKroYLwfpC/oxIOuaRVInUPM/cmtubMxePtu0 At8z7g/78Tzv9v4z5hMqim05uszYtUTQ4zrOaTm/FhWp6+mzZMwR1hm9Akw1zYxJKx7S exYw== 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 c38si1780315eda.46.2019.09.27.08.35.47; Fri, 27 Sep 2019 08:36:12 -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 S1727683AbfI0Peq (ORCPT + 99 others); Fri, 27 Sep 2019 11:34:46 -0400 Received: from 16.mo1.mail-out.ovh.net ([178.33.104.224]:40659 "EHLO 16.mo1.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727334AbfI0Pep (ORCPT ); Fri, 27 Sep 2019 11:34:45 -0400 X-Greylist: delayed 2209 seconds by postgrey-1.27 at vger.kernel.org; Fri, 27 Sep 2019 11:34:45 EDT Received: from player758.ha.ovh.net (unknown [10.108.54.9]) by mo1.mail-out.ovh.net (Postfix) with ESMTP id 8197E1918A9 for ; Fri, 27 Sep 2019 16:57:55 +0200 (CEST) Received: from sk2.org (unknown [65.39.69.237]) (Authenticated sender: steve@sk2.org) by player758.ha.ovh.net (Postfix) with ESMTPSA id 032C7A59A1F3; Fri, 27 Sep 2019 14:57:47 +0000 (UTC) From: Stephen Kitt To: Tero Kristo , Michael Turquette , Stephen Boyd , linux-omap@vger.kernel.org, linux-clk@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Stephen Kitt Subject: [PATCH] clk/ti/adpll: allocate room for terminating null Date: Fri, 27 Sep 2019 16:57:37 +0200 Message-Id: <20190927145737.7832-1-steve@sk2.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 2554385417407385031 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrfeeigdekudcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd 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 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; } -- 2.20.1