From: Fushuai Wang <fushuai.wang@linux.dev>
To: 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
Cc: linux-kernel@vger.kernel.org, x86@kernel.org,
wangfushuai@baidu.com, aliceryhl@google.com, ynorov@nvidia.com
Subject: [PATCH 2/2] x86/tlb: Convert copy_from_user() + kstrtouint() to kstrtouint_from_user()
Date: Fri, 16 Jan 2026 21:17:51 +0800 [thread overview]
Message-ID: <20260116131751.45768-3-fushuai.wang@linux.dev> (raw)
In-Reply-To: <20260116131751.45768-1-fushuai.wang@linux.dev>
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>
---
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
prev parent reply other threads:[~2026-01-16 13:18 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
2026-01-16 13:17 ` Fushuai Wang [this message]
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=20260116131751.45768-3-fushuai.wang@linux.dev \
--to=fushuai.wang@linux.dev \
--cc=aliceryhl@google.com \
--cc=bp@alien8.de \
--cc=bsegall@google.com \
--cc=dave.hansen@linux.intel.com \
--cc=dietmar.eggemann@arm.com \
--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 \
--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®