All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] firmware_loader: Replace simple_strtol() with kstrtoint()
@ 2024-04-26 20:25 Haoyang Liu
  2024-04-29 20:50 ` Russ Weight
  2024-05-04 18:22 ` Andy Shevchenko
  0 siblings, 2 replies; 4+ messages in thread
From: Haoyang Liu @ 2024-04-26 20:25 UTC (permalink / raw)
  To: Luis Chamberlain, Russ Weight, Greg Kroah-Hartman,
	Rafael J. Wysocki
  Cc: hust-os-kernel-patches, Haoyang Liu, Dan Carpenter, linux-kernel

simple_strtol() is obsolete, use kstrtoint() instead.

Signed-off-by: Haoyang Liu <tttturtleruss@hust.edu.cn>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/base/firmware_loader/sysfs.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/base/firmware_loader/sysfs.c b/drivers/base/firmware_loader/sysfs.c
index c9c93b47d9a5..4de1cb243bee 100644
--- a/drivers/base/firmware_loader/sysfs.c
+++ b/drivers/base/firmware_loader/sysfs.c
@@ -47,8 +47,12 @@ static ssize_t timeout_show(const struct class *class, const struct class_attrib
 static ssize_t timeout_store(const struct class *class, const struct class_attribute *attr,
 			     const char *buf, size_t count)
 {
-	int tmp_loading_timeout = simple_strtol(buf, NULL, 10);
+	int tmp_loading_timeout;
+	int res;
 
+	res = kstrtoint(buf, 10, &tmp_loading_timeout);
+	if (res < 0)
+		return res;
 	if (tmp_loading_timeout < 0)
 		tmp_loading_timeout = 0;
 
@@ -157,8 +161,12 @@ static ssize_t firmware_loading_store(struct device *dev,
 	struct fw_sysfs *fw_sysfs = to_fw_sysfs(dev);
 	struct fw_priv *fw_priv;
 	ssize_t written = count;
-	int loading = simple_strtol(buf, NULL, 10);
+	int loading;
+	int res;
 
+	res = kstrtoint(buf, 10, &loading);
+	if (res < 0)
+		return res;
 	mutex_lock(&fw_lock);
 	fw_priv = fw_sysfs->fw_priv;
 	if (fw_state_is_aborted(fw_priv) || fw_state_is_done(fw_priv))
-- 
2.25.1


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

* Re: [PATCH] firmware_loader: Replace simple_strtol() with kstrtoint()
  2024-04-26 20:25 [PATCH] firmware_loader: Replace simple_strtol() with kstrtoint() Haoyang Liu
@ 2024-04-29 20:50 ` Russ Weight
  2024-05-04 18:22 ` Andy Shevchenko
  1 sibling, 0 replies; 4+ messages in thread
From: Russ Weight @ 2024-04-29 20:50 UTC (permalink / raw)
  To: Haoyang Liu
  Cc: Luis Chamberlain, Greg Kroah-Hartman, Rafael J. Wysocki,
	hust-os-kernel-patches, Dan Carpenter, linux-kernel

On Sat, Apr 27, 2024 at 04:25:32AM +0800, Haoyang Liu wrote:
> simple_strtol() is obsolete, use kstrtoint() instead.
> 
> Signed-off-by: Haoyang Liu <tttturtleruss@hust.edu.cn>
> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>

Reviewed-by: Russ Weight <russ.weight@linux.dev>

> ---
>  drivers/base/firmware_loader/sysfs.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/base/firmware_loader/sysfs.c b/drivers/base/firmware_loader/sysfs.c
> index c9c93b47d9a5..4de1cb243bee 100644
> --- a/drivers/base/firmware_loader/sysfs.c
> +++ b/drivers/base/firmware_loader/sysfs.c
> @@ -47,8 +47,12 @@ static ssize_t timeout_show(const struct class *class, const struct class_attrib
>  static ssize_t timeout_store(const struct class *class, const struct class_attribute *attr,
>  			     const char *buf, size_t count)
>  {
> -	int tmp_loading_timeout = simple_strtol(buf, NULL, 10);
> +	int tmp_loading_timeout;
> +	int res;
>  
> +	res = kstrtoint(buf, 10, &tmp_loading_timeout);
> +	if (res < 0)
> +		return res;
>  	if (tmp_loading_timeout < 0)
>  		tmp_loading_timeout = 0;
>  
> @@ -157,8 +161,12 @@ static ssize_t firmware_loading_store(struct device *dev,
>  	struct fw_sysfs *fw_sysfs = to_fw_sysfs(dev);
>  	struct fw_priv *fw_priv;
>  	ssize_t written = count;
> -	int loading = simple_strtol(buf, NULL, 10);
> +	int loading;
> +	int res;
>  
> +	res = kstrtoint(buf, 10, &loading);
> +	if (res < 0)
> +		return res;
>  	mutex_lock(&fw_lock);
>  	fw_priv = fw_sysfs->fw_priv;
>  	if (fw_state_is_aborted(fw_priv) || fw_state_is_done(fw_priv))
> -- 
> 2.25.1
> 

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

* Re: [PATCH] firmware_loader: Replace simple_strtol() with kstrtoint()
  2024-04-26 20:25 [PATCH] firmware_loader: Replace simple_strtol() with kstrtoint() Haoyang Liu
  2024-04-29 20:50 ` Russ Weight
@ 2024-05-04 18:22 ` Andy Shevchenko
  2024-05-05  6:35   ` Greg Kroah-Hartman
  1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2024-05-04 18:22 UTC (permalink / raw)
  To: Haoyang Liu
  Cc: Luis Chamberlain, Russ Weight, Greg Kroah-Hartman,
	Rafael J. Wysocki, hust-os-kernel-patches, Dan Carpenter,
	linux-kernel

Sat, Apr 27, 2024 at 04:25:32AM +0800, Haoyang Liu kirjoitti:
> simple_strtol() is obsolete, use kstrtoint() instead.

It's not, but kstrtox() is preferred.

...


While I'm in support of this move, this might break userspace by making
stricter requirement on the input.

So this is just informative message.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH] firmware_loader: Replace simple_strtol() with kstrtoint()
  2024-05-04 18:22 ` Andy Shevchenko
@ 2024-05-05  6:35   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2024-05-05  6:35 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Haoyang Liu, Luis Chamberlain, Russ Weight, Rafael J. Wysocki,
	hust-os-kernel-patches, Dan Carpenter, linux-kernel

On Sat, May 04, 2024 at 09:22:08PM +0300, Andy Shevchenko wrote:
> Sat, Apr 27, 2024 at 04:25:32AM +0800, Haoyang Liu kirjoitti:
> > simple_strtol() is obsolete, use kstrtoint() instead.
> 
> It's not, but kstrtox() is preferred.
> 
> ...
> 
> 
> While I'm in support of this move, this might break userspace by making
> stricter requirement on the input.

Good point, I've dropped this so that others can test it better first.

thanks,

greg k-h

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

end of thread, other threads:[~2024-05-05  6:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-26 20:25 [PATCH] firmware_loader: Replace simple_strtol() with kstrtoint() Haoyang Liu
2024-04-29 20:50 ` Russ Weight
2024-05-04 18:22 ` Andy Shevchenko
2024-05-05  6:35   ` Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.