Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Shubhrajyoti D <shubhrajyoti@ti.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>

authored by

Shubhrajyoti D and committed by
Jean Delvare
e3cd9528 c4f99a2b

+6 -1
+6 -1
drivers/hwmon/lm75.c
··· 103 103 struct i2c_client *client = to_i2c_client(dev); 104 104 struct lm75_data *data = i2c_get_clientdata(client); 105 105 int nr = attr->index; 106 - long temp = simple_strtol(buf, NULL, 10); 106 + long temp; 107 + int error; 108 + 109 + error = strict_strtol(buf, 10, &temp); 110 + if (error) 111 + return error; 107 112 108 113 mutex_lock(&data->update_lock); 109 114 data->temp[nr] = LM75_TEMP_TO_REG(temp);