aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuan Mu <Ymu@winbond.com.tw>2005-11-23 18:44:21 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-24 02:04:26 -0500
commit2723ab91cb4019def10bdb01b0fecb85e6ac7884 (patch)
tree753a9a0096bb1e41d79e5ef58370d7cfa8152228
parent1adc123079207bf9ba5bcf3dbf52bcdb22f82c7c (diff)
[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>
-rw-r--r--drivers/hwmon/w83627hf.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index 4e9a04e1f08e..bbb3dcde146b 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -456,7 +456,9 @@ static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *a
456 (w83627thf == data->type || w83637hf == data->type)) 456 (w83627thf == data->type || w83637hf == data->type))
457 457
458 /* use VRM9 calculation */ 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 else 462 else
461 /* use VRM8 (standard) calculation */ 463 /* use VRM8 (standard) calculation */
462 data->in_min[0] = IN_TO_REG(val); 464 data->in_min[0] = IN_TO_REG(val);
@@ -481,7 +483,9 @@ static ssize_t store_regs_in_max0(struct device *dev, struct device_attribute *a
481 (w83627thf == data->type || w83637hf == data->type)) 483 (w83627thf == data->type || w83637hf == data->type))
482 484
483 /* use VRM9 calculation */ 485 /* use VRM9 calculation */
484 data->in_max[0] = (u8)(((val * 100) - 70000 + 244) / 488); 486 data->in_max[0] =
487 SENSORS_LIMIT(((val * 100) - 70000 + 244) / 488, 0,
488 255);
485 else 489 else
486 /* use VRM8 (standard) calculation */ 490 /* use VRM8 (standard) calculation */
487 data->in_max[0] = IN_TO_REG(val); 491 data->in_max[0] = IN_TO_REG(val);