]> err.no Git - linux-2.6/commitdiff
[PATCH] hwmon: Fix missing boundary check when setting W83627THF in0 limits
authorYuan Mu <Ymu@winbond.com.tw>
Wed, 23 Nov 2005 23:44:21 +0000 (15:44 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Thu, 24 Nov 2005 07:04:26 +0000 (23:04 -0800)
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>
drivers/hwmon/w83627hf.c

index 4e9a04e1f08e5eecbfa541a65740f9564e3659ff..bbb3dcde146bd8618c140d0bc1f33ed59b003489 100644 (file)
@@ -456,7 +456,9 @@ static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *a
                (w83627thf == data->type || w83637hf == data->type))
 
                /* use VRM9 calculation */
-               data->in_min[0] = (u8)(((val * 100) - 70000 + 244) / 488);
+               data->in_min[0] =
+                       SENSORS_LIMIT(((val * 100) - 70000 + 244) / 488, 0,
+                                       255);
        else
                /* use VRM8 (standard) calculation */
                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
                (w83627thf == data->type || w83637hf == data->type))
                
                /* use VRM9 calculation */
-               data->in_max[0] = (u8)(((val * 100) - 70000 + 244) / 488);
+               data->in_max[0] =
+                       SENSORS_LIMIT(((val * 100) - 70000 + 244) / 488, 0,
+                                       255);
        else
                /* use VRM8 (standard) calculation */
                data->in_max[0] = IN_TO_REG(val);