Commit e3cd9528 authored by Shubhrajyoti D's avatar Shubhrajyoti D Committed by Jean Delvare

hwmon: (lm75) Make the writing to sysfs more robust

Currently we get the checkpatch warning
consider using strict_strtol in preference to simple_strtol.
Also we should not allow any partially numeric values.
Signed-off-by: default avatarShubhrajyoti D <shubhrajyoti@ti.com>
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
parent c4f99a2b
...@@ -103,7 +103,12 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da, ...@@ -103,7 +103,12 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct lm75_data *data = i2c_get_clientdata(client); struct lm75_data *data = i2c_get_clientdata(client);
int nr = attr->index; int nr = attr->index;
long temp = simple_strtol(buf, NULL, 10); long temp;
int error;
error = strict_strtol(buf, 10, &temp);
if (error)
return error;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
data->temp[nr] = LM75_TEMP_TO_REG(temp); data->temp[nr] = LM75_TEMP_TO_REG(temp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment