mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH -next] macintosh/therm_adt746x: Replaced simple_strtol() with kstrtoint()
@ 2021-05-24 12:08 Liu Shixin
  2022-03-02 14:57 ` Christophe Leroy
  0 siblings, 1 reply; 2+ messages in thread
From: Liu Shixin @ 2021-05-24 12:08 UTC (permalink / raw)
  To: Colin Leroy; +Cc: linuxppc-dev, linux-kernel, Liu Shixin

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


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

end of thread, other threads:[~2022-03-02 14:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-24 12:08 [PATCH -next] macintosh/therm_adt746x: Replaced simple_strtol() with kstrtoint() Liu Shixin
2022-03-02 14:57 ` Christophe Leroy

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

all inboxes | Powered by JetHome®