All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric-Terminal <ericterminal@gmail.com>
To: asmadeus@codewreck.org, ericvh@kernel.org, lucho@ionkov.net
Cc: stefano.stabellini@amd.com, v9fs@lists.linux.dev,
	linux-kernel@vger.kernel.org, Yufan Chen <ericterminal@gmail.com>
Subject: [PATCH v3 2/2] 9p/trans_xen: replace simple_strto* with kstrtouint
Date: Tue, 24 Mar 2026 23:30:23 +0800	[thread overview]
Message-ID: <20260324153023.86853-3-ericterminal@gmail.com> (raw)
In-Reply-To: <20260324153023.86853-1-ericterminal@gmail.com>

From: Yufan Chen <ericterminal@gmail.com>

In xen_9pfs_front_init(), parse the backend version list as comma-separated
tokens with kstrtouint(), keep strict token validation, and explicitly
require protocol version 1 to be present.

This replaces the deprecated simple_strtoul(), 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 9p/trans_xen series.
- Refined commit message to focus on 9p changes.
- No functional changes since v2.

 net/9p/trans_xen.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c
index 85b9ebfaa..f9fb2db7a 100644
--- a/net/9p/trans_xen.c
+++ b/net/9p/trans_xen.c
@@ -413,23 +413,29 @@ static int xen_9pfs_front_init(struct xenbus_device *dev)
 	int ret, i;
 	struct xenbus_transaction xbt;
 	struct xen_9pfs_front_priv *priv;
-	char *versions, *v;
-	unsigned int max_rings, max_ring_order, len = 0;
+	char *versions, *v, *token;
+	bool version_1 = false;
+	unsigned int max_rings, max_ring_order, len = 0, version;
 
 	versions = xenbus_read(XBT_NIL, dev->otherend, "versions", &len);
 	if (IS_ERR(versions))
 		return PTR_ERR(versions);
-	for (v = versions; *v; v++) {
-		if (simple_strtoul(v, &v, 10) == 1) {
-			v = NULL;
-			break;
+	for (v = versions; (token = strsep(&v, ",")); ) {
+		if (!*token)
+			continue;
+
+		ret = kstrtouint(token, 10, &version);
+		if (ret) {
+			kfree(versions);
+			return ret;
 		}
-	}
-	if (v) {
-		kfree(versions);
-		return -EINVAL;
+		if (version == 1)
+			version_1 = true;
 	}
 	kfree(versions);
+	if (!version_1)
+		return -EINVAL;
+
 	max_rings = xenbus_read_unsigned(dev->otherend, "max-rings", 0);
 	if (max_rings < XEN_9PFS_NUM_RINGS)

  parent reply	other threads:[~2026-03-24 15:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-24 15:30 [PATCH v3 0/2] 9p/trans_xen: fixes and parser cleanup Eric-Terminal
2026-03-24 15:30 ` [PATCH v3 1/2] 9p/trans_xen: make cleanup idempotent after dataring alloc errors Eric-Terminal
2026-04-09  1:22   ` Stefano Stabellini
2026-03-24 15:30 ` Eric-Terminal [this message]
2026-04-09  1:30   ` [PATCH v3 2/2] 9p/trans_xen: replace simple_strto* with kstrtouint Stefano Stabellini
2026-04-16  2:07     ` Dominique Martinet

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=20260324153023.86853-3-ericterminal@gmail.com \
    --to=ericterminal@gmail.com \
    --cc=asmadeus@codewreck.org \
    --cc=ericvh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucho@ionkov.net \
    --cc=stefano.stabellini@amd.com \
    --cc=v9fs@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.