Skip to content

Commit 072e18d

Browse files
Hongbo Ligregkh
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e807c40 commit 072e18d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/misc/tsl2550.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ static ssize_t tsl2550_store_power_state(struct device *dev,
185185
{
186186
struct i2c_client *client = to_i2c_client(dev);
187187
struct tsl2550_data *data = i2c_get_clientdata(client);
188-
unsigned long val = simple_strtoul(buf, NULL, 10);
188+
unsigned long val;
189189
int ret;
190190

191-
if (val > 1)
191+
if (kstrtoul(buf, 10, &val) || val > 1)
192192
return -EINVAL;
193193

194194
mutex_lock(&data->update_lock);
@@ -217,10 +217,10 @@ static ssize_t tsl2550_store_operating_mode(struct device *dev,
217217
{
218218
struct i2c_client *client = to_i2c_client(dev);
219219
struct tsl2550_data *data = i2c_get_clientdata(client);
220-
unsigned long val = simple_strtoul(buf, NULL, 10);
220+
unsigned long val;
221221
int ret;
222222

223-
if (val > 1)
223+
if (kstrtoul(buf, 10, &val) || val > 1)
224224
return -EINVAL;
225225

226226
if (data->power_state == 0)

0 commit comments

Comments
 (0)