[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260117145615.53455-3-fushuai.wang@linux.dev>
Date: Sat, 17 Jan 2026 22:56:15 +0800
From: Fushuai Wang <fushuai.wang@...ux.dev>
To: mingo@...hat.com,
peterz@...radead.org,
juri.lelli@...hat.com,
vincent.guittot@...aro.org,
dietmar.eggemann@....com,
rostedt@...dmis.org,
bsegall@...gle.com,
mgorman@...e.de,
vschneid@...hat.com,
dave.hansen@...ux.intel.com,
luto@...nel.org,
tglx@...nel.org,
bp@...en8.de,
hpa@...or.com
Cc: linux-kernel@...r.kernel.org,
x86@...nel.org,
wangfushuai@...du.com,
aliceryhl@...gle.com,
ynorov@...dia.com
Subject: [PATCH v2 2/2] x86/tlb: Convert copy_from_user() + kstrtouint() to kstrtouint_from_user()
From: Fushuai Wang <wangfushuai@...du.com>
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>
Reviewed-by: Yury Norov <ynorov@...dia.com>
---
arch/x86/mm/tlb.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index f5b93e01e347..5e6a07306214 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -1802,17 +1802,12 @@ static ssize_t tlbflush_read_file(struct file *file, char __user *user_buf,
static ssize_t tlbflush_write_file(struct file *file,
const char __user *user_buf, size_t count, loff_t *ppos)
{
- char buf[32];
- ssize_t len;
int ceiling;
+ int err;
- len = min(count, sizeof(buf) - 1);
- if (copy_from_user(buf, user_buf, len))
- return -EFAULT;
-
- buf[len] = '\0';
- if (kstrtoint(buf, 0, &ceiling))
- return -EINVAL;
+ err = kstrtoint_from_user(user_buf, count, 0, &ceiling);
+ if (err)
+ return err;
if (ceiling < 0)
return -EINVAL;
--
2.36.1
Powered by blists - more mailing lists