lkml.org 
[lkml]   [2021]   [May]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH -next] macintosh/therm_adt746x: Replaced simple_strtol() with kstrtoint()
Date
The simple_strtol() function is deprecated in some situation since
it does not check for the range overflow. Use kstrtoint() instead.

Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
drivers/macintosh/therm_adt746x.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c
index 7e218437730c..0d7ef55126ce 100644
--- a/drivers/macintosh/therm_adt746x.c
+++ b/drivers/macintosh/therm_adt746x.c
@@ -352,7 +352,8 @@ static ssize_t store_##name(struct device *dev, struct device_attribute *attr, c
struct thermostat *th = dev_get_drvdata(dev); \
int val; \
int i; \
- val = simple_strtol(buf, NULL, 10); \
+ if (unlikely(kstrtoint(buf, 10, &val)) \
+ return -EINVAL; \
printk(KERN_INFO "Adjusting limits by %d degrees\n", val); \
limit_adjust = val; \
for (i=0; i < 3; i++) \
@@ -364,7 +365,8 @@ static ssize_t store_##name(struct device *dev, struct device_attribute *attr, c
static ssize_t store_##name(struct device *dev, struct device_attribute *attr, const char *buf, size_t n) \
{ \
int val; \
- val = simple_strtol(buf, NULL, 10); \
+ if (unlikely(kstrtoint(buf, 10, &val)) \
+ return -EINVAL; \
if (val < 0 || val > 255) \
return -EINVAL; \
printk(KERN_INFO "Setting specified fan speed to %d\n", val); \
--
2.18.0.huawei.25
\
 
 \ /
  Last update: 2021-05-24 13:35    [W:0.029 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site