Re: [PATCH] usb: misc: cytherm: replace deprecated simple_strtoul with kstrtoint
From: Greg KH
Date: Wed Jul 08 2026 - 11:36:19 EST
On Mon, Jun 22, 2026 at 01:31:24PM +0100, Jad Keskes wrote:
> simple_strtoul() is deprecated in favor of kstrtoint(). The old
> function silently accepts garbage input. kstrtoint() returns -EINVAL
> so the driver can actually tell the user they typed something stupid
> instead of accepting 0 and wondering why the thermometer isn't
> responding.
>
> The 0-255 clamping stays the same, just with proper error handling
> in front of it now.
>
> Signed-off-by: Jad Keskes <inasj268@xxxxxxxxx>
> ---
> drivers/usb/misc/cytherm.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c
> index b183df9826bc..81de3fecf3da 100644
> --- a/drivers/usb/misc/cytherm.c
> +++ b/drivers/usb/misc/cytherm.c
> @@ -85,7 +85,9 @@ static ssize_t brightness_store(struct device *dev, struct device_attribute *att
> if (!buffer)
> return 0;
>
> - cytherm->brightness = simple_strtoul(buf, NULL, 10);
> + retval = kstrtoint(buf, 10, &cytherm->brightness);
> + if (retval < 0)
> + return retval;
This changes the user/kernel functionality, are you sure it is safe to
do so?
What is wrong with leaving the current calls?
thanks,
greg k-h