From: "tip-bot2 for Fushuai Wang" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Yury Norov <ynorov@nvidia.com>,
Fushuai Wang <wangfushuai@baidu.com>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: sched/core] sched/debug: Convert copy_from_user() + kstrtouint() to kstrtouint_from_user()
Date: Thu, 22 Jan 2026 10:16:10 -0000 [thread overview]
Message-ID: <176907697014.510.1378420592339878350.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20260117145615.53455-2-fushuai.wang@linux.dev>
The following commit has been merged into the sched/core branch of tip:
Commit-ID: 4fe82cf3024a4bdd2571d584efc25598533d5c96
Gitweb: https://git.kernel.org/tip/4fe82cf3024a4bdd2571d584efc25598533d5c96
Author: Fushuai Wang <wangfushuai@baidu.com>
AuthorDate: Sat, 17 Jan 2026 22:56:14 +08:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Thu, 22 Jan 2026 11:11:16 +01:00
sched/debug: Convert copy_from_user() + kstrtouint() to kstrtouint_from_user()
Using kstrtouint_from_user() instead of copy_from_user() + kstrtouint()
makes the code simpler and less error-prone.
Suggested-by: Yury Norov <ynorov@nvidia.com>
Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Yury Norov <ynorov@nvidia.com>
Link: https://patch.msgid.link/20260117145615.53455-2-fushuai.wang@linux.dev
---
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 5f9b771..929fdf0 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)
+ return ret;
if (scaling >= SCHED_TUNABLESCALING_END)
return -EINVAL;
next prev parent reply other threads:[~2026-01-22 10:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-17 14:56 [PATCH v2 0/2] " Fushuai Wang
2026-01-17 14:56 ` [PATCH v2 1/2] sched/debug: " Fushuai Wang
2026-01-22 10:16 ` tip-bot2 for Fushuai Wang [this message]
2026-01-17 14:56 ` [PATCH v2 2/2] x86/tlb: " Fushuai Wang
2026-05-25 0:18 ` [tip: x86/cleanups] " tip-bot2 for 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=176907697014.510.1378420592339878350.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=wangfushuai@baidu.com \
--cc=x86@kernel.org \
--cc=ynorov@nvidia.com \
/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®