Skip to content

Commit

Permalink
hwmon: (lm75) Make the writing to sysfs more robust
Browse files Browse the repository at this point in the history
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: Shubhrajyoti D <shubhrajyoti@ti.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
  • Loading branch information
Shubhrajyoti D authored and Jean Delvare committed Oct 28, 2010
1 parent c4f99a2 commit e3cd952
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/hwmon/lm75.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 lm75_data *data = i2c_get_clientdata(client);
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);
data->temp[nr] = LM75_TEMP_TO_REG(temp);
Expand Down

0 comments on commit e3cd952

Please sign in to comment.