mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] edac: edac_device_sysfs: replace simple_strtoul with kstrtoul
@ 2026-06-23 11:53 Jad Keskes
  2026-07-07 21:48 ` Borislav Petkov
  0 siblings, 1 reply; 2+ messages in thread
From: Jad Keskes @ 2026-06-23 11:53 UTC (permalink / raw)
  To: Borislav Petkov, Tony Luck; +Cc: linux-edac, linux-kernel, Jad Keskes

simple_strtoul is deprecated.  These calls also didn't validate input -
echoing 'garbage' would just set the value to 0 with no error.

Use kstrtoul instead so bogus data gets -EINVAL back.

Signed-off-by: Jad Keskes <inasj268@gmail.com>
---
 drivers/edac/edac_device_sysfs.c | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c
index b1c2717cd023..da804ebe3626 100644
--- a/drivers/edac/edac_device_sysfs.c
+++ b/drivers/edac/edac_device_sysfs.c
@@ -37,8 +37,14 @@ static ssize_t edac_device_ctl_log_ue_store(struct edac_device_ctl_info
 					*ctl_info, const char *data,
 					size_t count)
 {
+	unsigned long val;
+	int ret;
+
 	/* if parameter is zero, turn off flag, if non-zero turn on flag */
-	ctl_info->log_ue = (simple_strtoul(data, NULL, 0) != 0);
+	ret = kstrtoul(data, 0, &val);
+	if (ret < 0)
+		return ret;
+	ctl_info->log_ue = !!val;
 
 	return count;
 }
@@ -54,8 +60,14 @@ static ssize_t edac_device_ctl_log_ce_store(struct edac_device_ctl_info
 					*ctl_info, const char *data,
 					size_t count)
 {
+	unsigned long val;
+	int ret;
+
 	/* if parameter is zero, turn off flag, if non-zero turn on flag */
-	ctl_info->log_ce = (simple_strtoul(data, NULL, 0) != 0);
+	ret = kstrtoul(data, 0, &val);
+	if (ret < 0)
+		return ret;
+	ctl_info->log_ce = !!val;
 
 	return count;
 }
@@ -71,8 +83,14 @@ static ssize_t edac_device_ctl_panic_on_ue_store(struct edac_device_ctl_info
 						 *ctl_info, const char *data,
 						 size_t count)
 {
+	unsigned long val;
+	int ret;
+
 	/* if parameter is zero, turn off flag, if non-zero turn on flag */
-	ctl_info->panic_on_ue = (simple_strtoul(data, NULL, 0) != 0);
+	ret = kstrtoul(data, 0, &val);
+	if (ret < 0)
+		return ret;
+	ctl_info->panic_on_ue = !!val;
 
 	return count;
 }
@@ -89,13 +107,16 @@ static ssize_t edac_device_ctl_poll_msec_store(struct edac_device_ctl_info
 					size_t count)
 {
 	unsigned long value;
+	int ret;
 
 	/* get the value and enforce that it is non-zero, must be at least
 	 * one millisecond for the delay period, between scans
 	 * Then cancel last outstanding delay for the work request
 	 * and set a new one.
 	 */
-	value = simple_strtoul(data, NULL, 0);
+	ret = kstrtoul(data, 0, &value);
+	if (ret < 0)
+		return ret;
 	edac_device_reset_delay_period(ctl_info, value);
 
 	return count;
-- 
2.54.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] edac: edac_device_sysfs: replace simple_strtoul with kstrtoul
  2026-06-23 11:53 [PATCH] edac: edac_device_sysfs: replace simple_strtoul with kstrtoul Jad Keskes
@ 2026-07-07 21:48 ` Borislav Petkov
  0 siblings, 0 replies; 2+ messages in thread
From: Borislav Petkov @ 2026-07-07 21:48 UTC (permalink / raw)
  To: Jad Keskes; +Cc: Tony Luck, linux-edac, linux-kernel

On Tue, Jun 23, 2026 at 12:53:23PM +0100, Jad Keskes wrote:
> simple_strtoul is deprecated.  These calls also didn't validate input -
> echoing 'garbage' would just set the value to 0 with no error.
> 
> Use kstrtoul instead so bogus data gets -EINVAL back.
> 
> Signed-off-by: Jad Keskes <inasj268@gmail.com>
> ---
>  drivers/edac/edac_device_sysfs.c | 29 +++++++++++++++++++++++++----
>  1 file changed, 25 insertions(+), 4 deletions(-)

Sashiko is reporting two pre-existing issues here:

https://sashiko.dev/#/patchset/20260623115323.519298-1-inasj268%40gmail.com

Would you like to take care of them too, in separate patches?

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-07 21:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-23 11:53 [PATCH] edac: edac_device_sysfs: replace simple_strtoul with kstrtoul Jad Keskes
2026-07-07 21:48 ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox