Commit 8fc518e4 authored by Yufan Chen's avatar Yufan Chen Committed by Dominique Martinet
Browse files

9p/trans_xen: replace simple_strto* with kstrtouint



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: default avatarYufan Chen <ericterminal@gmail.com>
Reviewed-by: default avatarStefano Stabellini <sstabellini@kernel.org>
Message-ID: <20260324153023.86853-3-ericterminal@gmail.com>
Signed-off-by: default avatarDominique Martinet <asmadeus@codewreck.org>
parent 72cb9ee4
Loading
Loading
Loading
Loading
+16 −10
Original line number Diff line number Diff line
@@ -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 (version == 1)
			version_1 = true;
	}
	if (v) {
	kfree(versions);
	if (!version_1)
		return -EINVAL;
	}
	kfree(versions);

	max_rings = xenbus_read_unsigned(dev->otherend, "max-rings", 0);
	if (max_rings < XEN_9PFS_NUM_RINGS)
		return -EINVAL;