From: 林濬哲 <m18667909625@163.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Wim Van Sebroeck <wim@linux-watchdog.org>,
linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org,
m18667909625@163.com
Subject: [PATCH v2 2/2] PM: hibernate: use kstrtouint to parse resume= device numbers
Date: Mon, 21 Sep 2026 14:29:14 +0800 [thread overview]
Message-ID: <20260922060000.10086.2-m18667909625@163.com> (raw)
In-Reply-To: <7b91e8cb-d068-484c-9a9f-2c19cb37f5ba@roeck-us.net>
simple_strtoul() is deprecated. Replace the base-16 parse with
kstrtouint(); the explicit trailing-character check the old code
needed is provided by kstrtouint() itself. As a side effect, values
wider than 32 bits are now rejected instead of being silently
truncated before the dev_t conversion.
Signed-off-by: Lin Junzhe <m18667909625@163.com>
Assisted-by: AI coding assistant (disclosed per kernel AI guidelines)
---
kernel/power/hibernate.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index d2479c69d71a..74f2d20518cc 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -14,6 +14,7 @@
#include <crypto/acompress.h>
#include <linux/blkdev.h>
#include <linux/export.h>
+#include <linux/kstrtox.h>
#include <linux/suspend.h>
#include <linux/reboot.h>
#include <linux/string.h>
@@ -1278,7 +1279,7 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
error = lookup_bdev(name, &dev);
if (error) {
unsigned maj, min, offset;
- char *p, dummy;
+ char dummy;
error = 0;
if (sscanf(name, "%u:%u%c", &maj, &min, &dummy) == 2 ||
@@ -1288,9 +1289,12 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
if (maj != MAJOR(dev) || min != MINOR(dev))
error = -EINVAL;
} else {
- dev = new_decode_dev(simple_strtoul(name, &p, 16));
- if (*p)
+ unsigned int val;
+
+ if (kstrtouint(name, 16, &val))
error = -EINVAL;
+ else
+ dev = new_decode_dev(val);
}
}
kfree(name);
--
2.54.0.windows.1
next prev parent reply other threads:[~2026-09-22 5:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 6:41 [PATCH 1/2] watchdog: use kstrtouint to parse softlockup_panic= 林濬哲
2026-09-21 14:21 ` Guenter Roeck
2026-09-21 6:29 ` 林濬哲 [this message]
2026-09-22 5:50 ` [PATCH v2 " 林濬哲
2026-09-22 13:28 ` Guenter Roeck
2026-09-21 6:29 ` [PATCH v3 1/2] PM: hibernate: use kstrtouint to parse resume= device numbers 林濬哲
2026-09-22 14:49 ` [PATCH v3 2/2] watchdog: use kstrtouint to parse softlockup_panic= 林濬哲
2026-09-22 16:02 ` Guenter Roeck
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=20260922060000.10086.2-m18667909625@163.com \
--to=m18667909625@163.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=wim@linux-watchdog.org \
/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