[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20260108095010.99059-2-thorsten.blum@linux.dev>
Date: Thu, 8 Jan 2026 10:50:08 +0100
From: Thorsten Blum <thorsten.blum@...ux.dev>
To: Heiko Carstens <hca@...ux.ibm.com>,
Vasily Gorbik <gor@...ux.ibm.com>,
Alexander Gordeev <agordeev@...ux.ibm.com>,
Christian Borntraeger <borntraeger@...ux.ibm.com>,
Sven Schnelle <svens@...ux.ibm.com>,
Thomas Gleixner <tglx@...utronix.de>,
Nam Cao <namcao@...utronix.de>,
Easwar Hariharan <easwar.hariharan@...ux.microsoft.com>,
Thomas Weißschuh <thomas.weissschuh@...utronix.de>,
Anna-Maria Behnsen <anna-maria@...utronix.de>
Cc: Thorsten Blum <thorsten.blum@...ux.dev>,
linux-s390@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] s390/time: Replace simple_strtoul with kstrtouint in sysfs online_store
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@...ux.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@...ux.dev>
GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4
Powered by blists - more mailing lists