Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp889936ybk; Sat, 9 May 2020 23:16:28 -0700 (PDT) X-Google-Smtp-Source: APiQypJMeoSY1YyHlaRr7mC1baWWIE8XRAl4TJLJGKdzKuJ93/YriElTe7E2VYmB6LtDE69KjX4k X-Received: by 2002:a17:906:855a:: with SMTP id h26mr8753776ejy.56.1589091388635; Sat, 09 May 2020 23:16:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589091388; cv=none; d=google.com; s=arc-20160816; b=B02/LSW7ZWo6QQ0iYGkMvDRM3xFHq0rbz88J22UCcdalfSJkdXQlH7XbFPXCeItCbW LNn/oVabO5QY9452ntIxwI0QiX4WIIMa2VRxFFQS6RXer1yV1l8sKQQpDq4vn8LeFnX8 oZ618RA4jk1T0Km5gCh/A0TdAh4t589owOcpb/bwQm2/CIHmH3O059eRMKoLjtchREUU hyQCpeAfu9SjwpqlFOzD+BqzKlRbtHX7xLSmHhxT1GwSgZTGoFc6sf3cNAVqOUnU6YhJ gqrYYVKK9ichl1GQ/gx6EOryujRUoV35s8bFOgcfnv2uQ718ko3fAfmyudZcFyFpUgg3 XL8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=hbEA9pbCiRU5fhTzbyvIVcz7HYVBh2r6nnewjmiDeV8=; b=Y9n328q7rVykGlvvyl98xdvHOH5CT2/fYV4wiHMbIl+P6SHshQkoa1f7eXZB1cqzoc JuV8IcQU2dl7KSFZSzNcgra0HlpfJpxFWbzCnBXw1FnnNLkYi2mgrU4l+580ORSwogU+ iRbp1xoefqmNZ2Vre9BcEyQVmZOnoAeQTxzm6AM14nlLM9jgddhz4cRyhzAnaI5vskDK PRykgzhJouOkISRBgDp59uZm3D9mS+mjlra7GqJSNQxpOOEc2m80GegG0WbWUGegz5hI fgZW9ZrYprticHrtlf8/cDGHDbbqyg+Ey970Fm6CFRSzlkeDgJcl+kSsBfnv90Zcrgry nc2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="ucm/1umG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z8si491287ejp.460.2020.05.09.23.16.05; Sat, 09 May 2020 23:16:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="ucm/1umG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725810AbgEJGO0 (ORCPT + 99 others); Sun, 10 May 2020 02:14:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:57788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725764AbgEJGOZ (ORCPT ); Sun, 10 May 2020 02:14:25 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E6ACE2082E; Sun, 10 May 2020 06:14:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589091265; bh=dhSX1koUXR01QNflrqzyeDk0HZwGZnOuulR+owPUVxA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ucm/1umG+61KjNyTKq2IX2ZBYcRg+6v/Mx/iyTwnFn9ufXLQC8aqrYWQiFPYuy7ap eUeKYsnKisIPlDOWh3qlbQuhDe39DkIeXMbpEWrZDcYHefB7xrrtgGL45LM5DaAhto tJN5JUcFYWgXPbSBWeJ9TDusCbJSFEB0MeuNI9FM= Date: Sun, 10 May 2020 08:14:22 +0200 From: Greg KH To: Chen Zhou Cc: linux@armlinux.org.uk, alexios.zavras@intel.com, tglx@linutronix.de, allison@lohutok.net, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH -next] arch/arm: use scnprintf() in l2x0_pmu_event_show() Message-ID: <20200510061422.GA3375088@kroah.com> References: <20200509083539.113156-1-chenzhou10@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200509083539.113156-1-chenzhou10@huawei.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 09, 2020 at 04:35:39PM +0800, Chen Zhou wrote: > snprintf() returns the number of bytes that would be written, > which may be greater than the the actual length to be written. > > show() methods should return the number of bytes printed into the > buffer. This is the return value of scnprintf(). > > Signed-off-by: Chen Zhou > --- > arch/arm/mm/cache-l2x0-pmu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm/mm/cache-l2x0-pmu.c b/arch/arm/mm/cache-l2x0-pmu.c > index 993fefdc167a..d20626451a2e 100644 > --- a/arch/arm/mm/cache-l2x0-pmu.c > +++ b/arch/arm/mm/cache-l2x0-pmu.c > @@ -343,7 +343,7 @@ static ssize_t l2x0_pmu_event_show(struct device *dev, > struct l2x0_event_attribute *lattr; > > lattr = container_of(attr, typeof(*lattr), attr); > - return snprintf(buf, PAGE_SIZE, "config=0x%x\n", lattr->config); > + return scnprintf(buf, PAGE_SIZE, "config=0x%x\n", lattr->config); This should just be replaced with sprintf() as there's no way such a string can go beyond PAGE_SIZE. And the "config=" part could be dropped as well, but now userspace probably requires it, that is sad. thanks, greg k-h