[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210524120835.1580420-1-liushixin2@huawei.com>
Date: Mon, 24 May 2021 20:08:35 +0800
From: Liu Shixin <liushixin2@...wei.com>
To: Colin Leroy <colin@...ino.net>
CC: <linuxppc-dev@...ts.ozlabs.org>, <linux-kernel@...r.kernel.org>,
"Liu Shixin" <liushixin2@...wei.com>
Subject: [PATCH -next] macintosh/therm_adt746x: Replaced simple_strtol() with kstrtoint()
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@...wei.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
Powered by blists - more mailing lists