Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Yufan Chen and committed by
Dominique Martinet
8fc518e4 72cb9ee4

+16 -10
+16 -10
net/9p/trans_xen.c
··· 413 413 int ret, i; 414 414 struct xenbus_transaction xbt; 415 415 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; 418 419 419 420 versions = xenbus_read(XBT_NIL, dev->otherend, "versions", &len); 420 421 if (IS_ERR(versions)) 421 422 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; 426 431 } 427 - } 428 - if (v) { 429 - kfree(versions); 430 - return -EINVAL; 432 + if (version == 1) 433 + version_1 = true; 431 434 } 432 435 kfree(versions); 436 + if (!version_1) 437 + return -EINVAL; 438 + 433 439 max_rings = xenbus_read_unsigned(dev->otherend, "max-rings", 0); 434 440 if (max_rings < XEN_9PFS_NUM_RINGS) 435 441 return -EINVAL;