[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <176907697014.510.1378420592339878350.tip-bot2@tip-bot2>
Date: Thu, 22 Jan 2026 10:16:10 -0000
From: "tip-bot2 for Fushuai Wang" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Yury Norov <ynorov@...dia.com>, Fushuai Wang <wangfushuai@...du.com>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: sched/core] sched/debug: Convert copy_from_user() +
kstrtouint() to kstrtouint_from_user()
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@...du.com>
AuthorDate: Sat, 17 Jan 2026 22:56:14 +08:00
Committer: Peter Zijlstra <peterz@...radead.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@...dia.com>
Signed-off-by: Fushuai Wang <wangfushuai@...du.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Reviewed-by: Yury Norov <ynorov@...dia.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;
Powered by blists - more mailing lists