Skip to content

Commit 8fc518e

Browse files
Eric-Terminalmartinetd
authored andcommitted
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: Yufan Chen <ericterminal@gmail.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> Message-ID: <20260324153023.86853-3-ericterminal@gmail.com> Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
1 parent 72cb9ee commit 8fc518e

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

net/9p/trans_xen.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -413,23 +413,29 @@ static int xen_9pfs_front_init(struct xenbus_device *dev)
413413
int ret, i;
414414
struct xenbus_transaction xbt;
415415
struct xen_9pfs_front_priv *priv;
416-
char *versions, *v;
417-
unsigned int max_rings, max_ring_order, len = 0;
416+
char *versions, *v, *token;
417+
bool version_1 = false;
418+
unsigned int max_rings, max_ring_order, len = 0, version;
418419

419420
versions = xenbus_read(XBT_NIL, dev->otherend, "versions", &len);
420421
if (IS_ERR(versions))
421422
return PTR_ERR(versions);
422-
for (v = versions; *v; v++) {
423-
if (simple_strtoul(v, &v, 10) == 1) {
424-
v = NULL;
425-
break;
423+
for (v = versions; (token = strsep(&v, ",")); ) {
424+
if (!*token)
425+
continue;
426+
427+
ret = kstrtouint(token, 10, &version);
428+
if (ret) {
429+
kfree(versions);
430+
return ret;
426431
}
427-
}
428-
if (v) {
429-
kfree(versions);
430-
return -EINVAL;
432+
if (version == 1)
433+
version_1 = true;
431434
}
432435
kfree(versions);
436+
if (!version_1)
437+
return -EINVAL;
438+
433439
max_rings = xenbus_read_unsigned(dev->otherend, "max-rings", 0);
434440
if (max_rings < XEN_9PFS_NUM_RINGS)
435441
return -EINVAL;

0 commit comments

Comments
 (0)