[PATCH] hwmon: Fix missing boundary check when setting W83627THF in0 limits

Add SENSORS_LIMIT in store VCore limit functions. This fixes a potential
u8 overflow on out-of-range user input.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Yuan Mu and committed by Linus Torvalds 2723ab91 1adc1230

+6 -2
+6 -2
drivers/hwmon/w83627hf.c
··· 456 456 (w83627thf == data->type || w83637hf == data->type)) 457 457 458 458 /* use VRM9 calculation */ 459 - data->in_min[0] = (u8)(((val * 100) - 70000 + 244) / 488); 459 + data->in_min[0] = 460 + SENSORS_LIMIT(((val * 100) - 70000 + 244) / 488, 0, 461 + 255); 460 462 else 461 463 /* use VRM8 (standard) calculation */ 462 464 data->in_min[0] = IN_TO_REG(val); ··· 483 481 (w83627thf == data->type || w83637hf == data->type)) 484 482 485 483 /* use VRM9 calculation */ 486 - data->in_max[0] = (u8)(((val * 100) - 70000 + 244) / 488); 484 + data->in_max[0] = 485 + SENSORS_LIMIT(((val * 100) - 70000 + 244) / 488, 0, 486 + 255); 487 487 else 488 488 /* use VRM8 (standard) calculation */ 489 489 data->in_max[0] = IN_TO_REG(val);