From: Haoyu Lu <hechushiguitu666@gmail.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>,
Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
Haoyu Lu <hechushiguitu666@gmail.com>
Subject: [PATCH 1/2] mtd: mtdoops: replace simple_strtoul with kstrtouint
Date: Fri, 10 Apr 2026 21:37:34 +0800 [thread overview]
Message-ID: <20260410133739.1632-1-hechushiguitu666@gmail.com> (raw)
Replace deprecated simple_strtoul with kstrtouint for better error
handling and type safety. The kstrtouint function provides stricter
validation, automatically rejecting inputs like "123abc" that
simple_strtoul would partially accept.
Using kstrtouint avoids unsigned long to int conversion and is more
appropriate for MTD device indices which are non-negative integers.
Signed-off-by: Haoyu Lu <hechushiguitu666@gmail.com>
---
drivers/mtd/mtdoops.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c
index b88083751a0c..39df7ce8f55f 100644
--- a/drivers/mtd/mtdoops.c
+++ b/drivers/mtd/mtdoops.c
@@ -403,8 +403,7 @@ static struct mtd_notifier mtdoops_notifier = {
static int __init mtdoops_init(void)
{
struct mtdoops_context *cxt = &oops_cxt;
- int mtd_index;
- char *endp;
+ unsigned int mtd_index;
if (strlen(mtddev) == 0) {
pr_err("mtd device (mtddev=name/number) must be supplied\n");
@@ -421,9 +420,9 @@ static int __init mtdoops_init(void)
/* Setup the MTD device to use */
cxt->mtd_index = -1;
- mtd_index = simple_strtoul(mtddev, &endp, 0);
- if (*endp == '\0')
+ if (kstrtouint(mtddev, 0, &mtd_index) == 0) {
cxt->mtd_index = mtd_index;
+ }
cxt->oops_buf = vmalloc(record_size);
if (!cxt->oops_buf)
--
2.53.0.windows.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next reply other threads:[~2026-04-10 13:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-10 13:37 Haoyu Lu [this message]
2026-04-10 13:37 ` [PATCH 2/2] mtd: mtdsuper: replace simple_strtoul with kstrtouint Haoyu Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260410133739.1632-1-hechushiguitu666@gmail.com \
--to=hechushiguitu666@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox