From: Haoyu Lu Date: Fri, 10 Apr 2026 13:37:35 +0000 (+0800) Subject: mtd: mtdsuper: replace simple_strtoul with kstrtouint X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a92a9a49288d1aad67bd12457c80a1e3f463d85b;p=thirdparty%2Flinux.git mtd: mtdsuper: replace simple_strtoul with kstrtouint Modernize string-to-number conversion in mtdsuper.c by replacing simple_strtoul with kstrtouint. This change provides proper type safety for MTD device numbers which are non-negative integers. Using kstrtouint avoids unsigned long to int conversion and is more appropriate for device indices. The debug output format specifier is updated to %u for unsigned int. Signed-off-by: Haoyu Lu Signed-off-by: Miquel Raynal --- diff --git a/drivers/mtd/mtdsuper.c b/drivers/mtd/mtdsuper.c index b7e3763c47f0..c709ff7aa6b5 100644 --- a/drivers/mtd/mtdsuper.c +++ b/drivers/mtd/mtdsuper.c @@ -132,12 +132,12 @@ int get_tree_mtd(struct fs_context *fc, } else if (isdigit(fc->source[3])) { /* mount by MTD device number name */ - char *endptr; + unsigned int mtdnr_val; - mtdnr = simple_strtoul(fc->source + 3, &endptr, 0); - if (!*endptr) { + if (kstrtouint(fc->source + 3, 0, &mtdnr_val) == 0) { + mtdnr = mtdnr_val; /* It was a valid number */ - pr_debug("MTDSB: mtd%%d, mtdnr %d\n", mtdnr); + pr_debug("MTDSB: mtd%%d, mtdnr %u\n", mtdnr_val); return mtd_get_sb_by_nr(fc, mtdnr, fill_super); } }