Skip to contentSkip to conversation

devtmpfs: Replace simple_strtoul with kstrtoint in mount_param

PATCH New Thorsten Blum 1 participant 1 message Dec 20, 2025 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 devtmpfs: Replace simple_strtoul with kstrtoint in mount_param

Replace simple_strtoul() with the recommended kstrtoint() for parsing the 'devtmpfs.mount=' boot parameter. Unlike simple_strtoul(), which returns an unsigned long, kstrtoint() converts the string directly to int and avoids implicit casting.

Check the return value of kstrtoint() and reject invalid values. This adds error handling while preserving behavior for existing values, and removes use of the deprecated simple_strtoul() helper. The current code silently sets 'mount_dev = 0' if parsing fails, instead of leaving the default value (IS_ENABLED(CONFIG_DEVTMPFS_MOUNT)) unchanged.

---
 drivers/base/devtmpfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/base/devtmpfs.c +1 -2
index 194b44075ac7..3f7d724ef242 100644
@@ -56,8 +56,7 @@ static struct req {
 
 static int __init mount_param(char *str)
 {
-	mount_dev = simple_strtoul(str, NULL, 0);
-	return 1;
+	return kstrtoint(str, 0, &mount_dev) == 0;
 }
 __setup("devtmpfs.mount=", mount_param);
 
Signature · 2 lines
Thorsten Blum <[email protected]>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4