public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: Thorsten Blum <thorsten.blum@linux.dev>
To: "Heiko Carstens" <hca@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Sven Schnelle" <svens@linux.ibm.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Nam Cao" <namcao@linutronix.de>,
	"Easwar Hariharan" <easwar.hariharan@linux.microsoft.com>,
	"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
	"Anna-Maria Behnsen" <anna-maria@linutronix.de>
Cc: Thorsten Blum <thorsten.blum@linux.dev>,
	linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] s390/time: Replace simple_strtoul with kstrtouint in sysfs online_store
Date: Thu,  8 Jan 2026 10:50:08 +0100	[thread overview]
Message-ID: <20260108095010.99059-2-thorsten.blum@linux.dev> (raw)

Replace simple_strtoul() with the recommended kstrtouint() for parsing
the input buffer. Unlike simple_strtoul(), which returns an unsigned
long, kstrtouint() converts the string directly to an unsigned integer
and avoids implicit casting.

Check the return value of kstrtouint() 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 'value = 0' if parsing fails, instead of returning
-EINVAL.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 arch/s390/kernel/time.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c
index bd0df61d1907..8439516dc4c4 100644
--- a/arch/s390/kernel/time.c
+++ b/arch/s390/kernel/time.c
@@ -787,7 +787,8 @@ static ssize_t online_store(struct device *dev,
 {
 	unsigned int value;
 
-	value = simple_strtoul(buf, NULL, 0);
+	if (kstrtouint(buf, 0, &value))
+		return -EINVAL;
 	if (value != 0 && value != 1)
 		return -EINVAL;
 	if (!test_bit(CLOCK_SYNC_HAS_STP, &clock_sync_flags))
-- 
Thorsten Blum <thorsten.blum@linux.dev>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4


                 reply	other threads:[~2026-01-08  9:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260108095010.99059-2-thorsten.blum@linux.dev \
    --to=thorsten.blum@linux.dev \
    --cc=agordeev@linux.ibm.com \
    --cc=anna-maria@linutronix.de \
    --cc=borntraeger@linux.ibm.com \
    --cc=easwar.hariharan@linux.microsoft.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=namcao@linutronix.de \
    --cc=svens@linux.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.weissschuh@linutronix.de \
    /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