hwmon: (lm95241) Check validity of input values

This clears the following build-time warnings I was seeing:

drivers/hwmon/lm95241.c: In function "set_interval":
drivers/hwmon/lm95241.c:132:15: warning: ignoring return value of "strict_strtol", declared with attribute warn_unused_result
drivers/hwmon/lm95241.c: In function "set_max2":
drivers/hwmon/lm95241.c:278:1: warning: ignoring return value of "strict_strtol", declared with attribute warn_unused_result
drivers/hwmon/lm95241.c: In function "set_max1":
drivers/hwmon/lm95241.c:277:1: warning: ignoring return value of "strict_strtol", declared with attribute warn_unused_result
drivers/hwmon/lm95241.c: In function "set_min2":
drivers/hwmon/lm95241.c:249:1: warning: ignoring return value of "strict_strtol", declared with attribute warn_unused_result
drivers/hwmon/lm95241.c: In function "set_min1":
drivers/hwmon/lm95241.c:248:1: warning: ignoring return value of "strict_strtol", declared with attribute warn_unused_result
drivers/hwmon/lm95241.c: In function "set_type2":
drivers/hwmon/lm95241.c:220:1: warning: ignoring return value of "strict_strtol", declared with attribute warn_unused_result
drivers/hwmon/lm95241.c: In function "set_type1":
drivers/hwmon/lm95241.c:219:1: warning: ignoring return value of "strict_strtol", declared with attribute warn_unused_result

This also fixes a small race in set_interval() as a side effect: by
working with a temporary local variable we prevent data->interval from
being accessed at a time it contains the interval value in the wrong
unit.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Davide Rizzo <elpa.rizzo@gmail.com>

authored by Jean Delvare and committed by Jean Delvare 61ec2da5 2aa25c22

+14 -5
+14 -5
drivers/hwmon/lm95241.c
··· 128 128 { 129 129 struct i2c_client *client = to_i2c_client(dev); 130 130 struct lm95241_data *data = i2c_get_clientdata(client); 131 + unsigned long val; 131 132 132 - strict_strtol(buf, 10, &data->interval); 133 - data->interval = data->interval * HZ / 1000; 133 + if (strict_strtoul(buf, 10, &val) < 0) 134 + return -EINVAL; 135 + 136 + data->interval = val * HZ / 1000; 134 137 135 138 return count; 136 139 } ··· 191 188 struct lm95241_data *data = i2c_get_clientdata(client); \ 192 189 \ 193 190 long val; \ 194 - strict_strtol(buf, 10, &val); \ 191 + \ 192 + if (strict_strtol(buf, 10, &val) < 0) \ 193 + return -EINVAL; \ 195 194 \ 196 195 if ((val == 1) || (val == 2)) { \ 197 196 \ ··· 232 227 struct lm95241_data *data = i2c_get_clientdata(client); \ 233 228 \ 234 229 long val; \ 235 - strict_strtol(buf, 10, &val); \ 230 + \ 231 + if (strict_strtol(buf, 10, &val) < 0) \ 232 + return -EINVAL;\ 236 233 \ 237 234 mutex_lock(&data->update_lock); \ 238 235 \ ··· 263 256 struct lm95241_data *data = i2c_get_clientdata(client); \ 264 257 \ 265 258 long val; \ 266 - strict_strtol(buf, 10, &val); \ 259 + \ 260 + if (strict_strtol(buf, 10, &val) < 0) \ 261 + return -EINVAL; \ 267 262 \ 268 263 mutex_lock(&data->update_lock); \ 269 264 \