Commit 2723ab91 authored by Yuan Mu's avatar Yuan Mu Committed by Linus Torvalds

[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: default avatarJean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 1adc1230
...@@ -456,7 +456,9 @@ static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *a ...@@ -456,7 +456,9 @@ static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *a
(w83627thf == data->type || w83637hf == data->type)) (w83627thf == data->type || w83637hf == data->type))
/* use VRM9 calculation */ /* 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 else
/* use VRM8 (standard) calculation */ /* use VRM8 (standard) calculation */
data->in_min[0] = IN_TO_REG(val); 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,7 +483,9 @@ static ssize_t store_regs_in_max0(struct device *dev, struct device_attribute *a
(w83627thf == data->type || w83637hf == data->type)) (w83627thf == data->type || w83637hf == data->type))
/* use VRM9 calculation */ /* 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 else
/* use VRM8 (standard) calculation */ /* use VRM8 (standard) calculation */
data->in_max[0] = IN_TO_REG(val); data->in_max[0] = IN_TO_REG(val);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment