[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20240830080311.3545307-1-lihongbo22@huawei.com>
Date: Fri, 30 Aug 2024 16:03:11 +0800
From: Hongbo Li <lihongbo22@...wei.com>
To: <arnd@...db.de>, <gregkh@...uxfoundation.org>
CC: <lihongbo22@...wei.com>, <linux-kernel@...r.kernel.org>
Subject: [PATCH -next] misc: tsl2550: replace simple_strtoul to kstrtoul
The function simple_strtoul performs no error checking
in scenarios where the input value overflows the intended
output variable.
We can replace the use of the simple_strtoul with the safer
alternatives kstrtoul.
Signed-off-by: Hongbo Li <lihongbo22@...wei.com>
---
drivers/misc/tsl2550.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/misc/tsl2550.c b/drivers/misc/tsl2550.c
index 2ad4387c9837..1a7796ab3fad 100644
--- a/drivers/misc/tsl2550.c
+++ b/drivers/misc/tsl2550.c
@@ -185,10 +185,10 @@ static ssize_t tsl2550_store_power_state(struct device *dev,
{
struct i2c_client *client = to_i2c_client(dev);
struct tsl2550_data *data = i2c_get_clientdata(client);
- unsigned long val = simple_strtoul(buf, NULL, 10);
+ unsigned long val;
int ret;
- if (val > 1)
+ if (kstrtoul(buf, 10, &val) || val > 1)
return -EINVAL;
mutex_lock(&data->update_lock);
@@ -217,10 +217,10 @@ static ssize_t tsl2550_store_operating_mode(struct device *dev,
{
struct i2c_client *client = to_i2c_client(dev);
struct tsl2550_data *data = i2c_get_clientdata(client);
- unsigned long val = simple_strtoul(buf, NULL, 10);
+ unsigned long val;
int ret;
- if (val > 1)
+ if (kstrtoul(buf, 10, &val) || val > 1)
return -EINVAL;
if (data->power_state == 0)
--
2.34.1
Powered by blists - more mailing lists