[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200109080330.GA2579993@kroah.com>
Date: Thu, 9 Jan 2020 09:03:30 +0100
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: liuyang34 <yangliuxm34@...il.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...hat.com>,
Namhyung Kim <namhyung@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Borislav Petkov <bp@...en8.de>,
"H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
Darren Hart <dvhart@...radead.org>,
Andy Shevchenko <andy@...radead.org>,
Richard Fontana <rfontana@...hat.com>,
Allison Randal <allison@...utok.net>,
linux-kernel@...r.kernel.org, platform-driver-x86@...r.kernel.org,
liuyang34 <liuyang34@...omi.com>
Subject: Re: [PATCH] x86: event, use scnprintf instead of snprintf
On Thu, Jan 09, 2020 at 02:36:26PM +0800, liuyang34 wrote:
> the return size will low than PAGE_SIZE but maybe over 40 in show_sysctl_tfa,
> so use scnprintf instead of snprintf to get real size
>
> Signed-off-by: liuyang34 <liuyang34@...omi.com>
> ---
> arch/x86/events/intel/core.c | 6 +++---
> arch/x86/events/intel/pt.c | 2 +-
> arch/x86/platform/uv/uv_sysfs.c | 4 ++--
> 3 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
> index 3be51aa..bf287b4 100644
> --- a/arch/x86/events/intel/core.c
> +++ b/arch/x86/events/intel/core.c
> @@ -4372,7 +4372,7 @@ static ssize_t show_sysctl_tfa(struct device *cdev,
> struct device_attribute *attr,
> char *buf)
> {
> - return snprintf(buf, 40, "%d\n", allow_tsx_force_abort);
> + return scnprintf(buf, 40, "%d\n", allow_tsx_force_abort);
No, just use sprintf() for all of these. We "know" the buffer size is
big enough for a single number. There's no need for fancy checks for
any sysfs file.
thanks,
greg k-h
Powered by blists - more mailing lists