diff options
author | Yuan Mu <Ymu@winbond.com.tw> | 2005-11-14 23:08:38 +0100 |
---|---|---|
committer | Chris Wright <chrisw@osdl.org> | 2005-11-24 14:10:12 -0800 |
commit | 30b2b8ee1866188c1f86aefe7dedca4b9681772f (patch) | |
tree | 04713dab1bb9e6cfb495a8e0df1f7cb88909dab2 | |
parent | fb69773ded08e5b679db97a84aa7ce371c5f6208 (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: Chris Wright <chrisw@osdl.org>
-rw-r--r-- | drivers/hwmon/w83627hf.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index 3479dc5208e2..b986f917e995 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c @@ -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); |