mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-30 06:10:56 +00:00
[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: Chris Wright <chrisw@osdl.org>
This commit is contained in:
parent
fb69773ded
commit
30b2b8ee18
1 changed files with 6 additions and 2 deletions
|
@ -454,7 +454,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);
|
||||
|
@ -479,7 +481,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);
|
||||
|
|
Loading…
Reference in a new issue