From: Eric-Terminal <ericterminal@gmail.com>
To: horms@kernel.org, davem@davemloft.net, kuba@kernel.org
Cc: netdev@vger.kernel.org, bridge@lists.linux.dev,
linux-nfs@vger.kernel.org, Yufan Chen <ericterminal@gmail.com>
Subject: [PATCH v3 2/2] net: sunrpc: replace deprecated simple_strtol with kstrtouint
Date: Tue, 24 Mar 2026 23:30:36 +0800 [thread overview]
Message-ID: <20260324153036.86901-3-ericterminal@gmail.com> (raw)
In-Reply-To: <20260324153036.86901-1-ericterminal@gmail.com>
From: Yufan Chen <ericterminal@gmail.com>
In proc_dodebug(), trim trailing whitespace and use kstrtouint() for
full-token conversion, preserving acceptance of surrounding whitespace
while rejecting malformed input.
This replaces the deprecated simple_strtol(), improves error reporting
consistency, and avoids partially parsed values in control paths.
Signed-off-by: Yufan Chen <ericterminal@gmail.com>
---
v3:
- Split from mixed series into a dedicated net series.
- No functional changes since v2.
net/sunrpc/sysctl.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c
index bdb587a72..07072218b 100644
--- a/net/sunrpc/sysctl.c
+++ b/net/sunrpc/sysctl.c
@@ -12,6 +12,7 @@
#include <linux/linkage.h>
#include <linux/ctype.h>
#include <linux/fs.h>
+#include <linux/kernel.h>
#include <linux/sysctl.h>
#include <linux/module.h>
@@ -65,10 +66,11 @@ static int
proc_dodebug(const struct ctl_table *table, int write, void *buffer, size_t *lenp,
loff_t *ppos)
{
- char tmpbuf[20], *s = NULL;
+ char tmpbuf[20];
char *p;
unsigned int value;
size_t left, len;
+ int ret;
if ((*ppos && !write) || !*lenp) {
*lenp = 0;
@@ -89,19 +91,17 @@ proc_dodebug(const struct ctl_table *table, int write, void *buffer, size_t *len
if (left > sizeof(tmpbuf) - 1)
return -EINVAL;
memcpy(tmpbuf, p, left);
+
+ while (left && isspace(tmpbuf[left - 1]))
+ left--;
tmpbuf[left] = '\0';
+ if (!tmpbuf[0])
+ goto done;
- value = simple_strtol(tmpbuf, &s, 0);
- if (s) {
- left -= (s - tmpbuf);
- if (left && !isspace(*s))
- return -EINVAL;
- while (left && isspace(*s)) {
- left--;
- s++;
- }
- } else
- left = 0;
+ ret = kstrtouint(tmpbuf, 0, &value);
+ if (ret)
+ return ret;
+ left = 0;
*(unsigned int *) table->data = value;
/* Display the RPC tasks on writing to rpc_debug */
if (strcmp(table->procname, "rpc_debug") == 0)
--
2.47.3
prev parent reply other threads:[~2026-03-24 15:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-24 15:30 [PATCH v3 0/2] net: replace deprecated simple_strto* parsers Eric-Terminal
2026-03-24 15:30 ` [PATCH v3 1/2] net: bridge: replace deprecated simple_strtoul with kstrtoul Eric-Terminal
2026-03-24 15:30 ` Eric-Terminal [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=20260324153036.86901-3-ericterminal@gmail.com \
--to=ericterminal@gmail.com \
--cc=bridge@lists.linux.dev \
--cc=davem@davemloft.net \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=netdev@vger.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