Make the writing to sysfs more robust.
RFC PATCH 1/1 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 Shubhrajyoti D <[email protected]>
--- drivers/hwmon/lm75.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/hwmon/lm75.c +5 -1
@@ -103,7 +103,11 @@ 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);
Signature · 7 lines
1.7.0.4 _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 14 lines · Shubhrajyoti D
Currently we get the checkpatch warning
consider usingstrict_strtolin preference tosimple_strtolAlso we should not allow any partially numeric valuesSigned-off-by Shubhrajyoti D <[email protected]>--- drivers/hwmon/lm75.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)drivers/hwmon/lm75.c +0
-0
drivers/hwmon/lm75.c static ssize_t set_temp(struct device *dev, struct device_attribute *da, · line 107
Quoted 6 lines
drivers/hwmon/lm75.c +2
-1@@ -103,7 +103,11 @@ 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;
Except for the missing blank line here, which I've added myself, it looks good. Patch applied, thanks!
Quoted 6 lines
drivers/hwmon/lm75.c +3
-0+ error =strict_strtol (buf,10 , &temp); +if (error) +return error;mutex_lock (&data->update_lock); data->temp[nr] =LM75_TEMP_TO_REG (temp);
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors