From: Yury Norov <ynorov@nvidia.com>
To: Fushuai Wang <fushuai.wang@linux.dev>
Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
vschneid@redhat.com, dave.hansen@linux.intel.com,
luto@kernel.org, tglx@kernel.org, bp@alien8.de, hpa@zytor.com,
linux-kernel@vger.kernel.org, x86@kernel.org,
wangfushuai@baidu.com, aliceryhl@google.com
Subject: Re: [PATCH 1/2] sched/debug: Convert copy_from_user() + kstrtouint() to kstrtouint_from_user()
Date: Fri, 16 Jan 2026 12:04:55 -0500 [thread overview]
Message-ID: <aWpvtxvO-AZ1tvDE@yury> (raw)
In-Reply-To: <20260116131751.45768-2-fushuai.wang@linux.dev>
On Fri, Jan 16, 2026 at 09:17:50PM +0800, Fushuai Wang wrote:
> From: Fushuai Wang <wangfushuai@baidu.com>
>
> Using kstrtouint_from_user() instead of copy_from_user() + kstrtouint()
> makes the code simpler and less error-prone.
>
> Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
> ---
> kernel/sched/debug.c | 14 ++++----------
> 1 file changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
> index 41caa22e0680..1091f9046260 100644
> --- a/kernel/sched/debug.c
> +++ b/kernel/sched/debug.c
> @@ -172,18 +172,12 @@ static const struct file_operations sched_feat_fops = {
> static ssize_t sched_scaling_write(struct file *filp, const char __user *ubuf,
> size_t cnt, loff_t *ppos)
> {
> - char buf[16];
> unsigned int scaling;
> + int ret;
>
> - if (cnt > 15)
> - cnt = 15;
> -
> - if (copy_from_user(&buf, ubuf, cnt))
> - return -EFAULT;
> - buf[cnt] = '\0';
> -
> - if (kstrtouint(buf, 10, &scaling))
> - return -EINVAL;
> + ret = kstrtouint_from_user(ubuf, cnt, 10, &scaling);
> + if (ret < 0)
> + return ret;
This thing returns 0 on success, so I think you could better do:
if (ret)
return ret;
With that, for the series:
Suggested-by: Yury Norov <ynorov@nvidia.com>
Reviewed-by: Yury Norov <ynorov@nvidia.com>
Thanks,
Yury
>
> if (scaling >= SCHED_TUNABLESCALING_END)
> return -EINVAL;
> --
> 2.36.1
>
next prev parent reply other threads:[~2026-01-16 17:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-16 13:17 [PATCH 0/2] " Fushuai Wang
2026-01-16 13:17 ` [PATCH 1/2] sched/debug: " Fushuai Wang
2026-01-16 17:04 ` Yury Norov [this message]
2026-01-16 13:17 ` [PATCH 2/2] x86/tlb: " Fushuai Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aWpvtxvO-AZ1tvDE@yury \
--to=ynorov@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bp@alien8.de \
--cc=bsegall@google.com \
--cc=dave.hansen@linux.intel.com \
--cc=dietmar.eggemann@arm.com \
--cc=fushuai.wang@linux.dev \
--cc=hpa@zytor.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=wangfushuai@baidu.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®