diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2013-12-12 08:05:33 +0100 |
---|---|---|
committer | Jean Delvare <khali@endymion.delvare> | 2013-12-12 08:05:33 +0100 |
commit | 3806b45ba4655147a011df03242cc197ab986c43 (patch) | |
tree | 6f16fdaab2125caf51cd1c9b2fb9cd9e1eb3674f /drivers/hwmon/vt8231.c | |
parent | hwmon: (w83l768ng) Fix fan speed control range (diff) | |
download | linux-3806b45ba4655147a011df03242cc197ab986c43.tar.xz linux-3806b45ba4655147a011df03242cc197ab986c43.zip |
hwmon: Prevent some divide by zeros in FAN_TO_REG()
The "rpm * div" operations can overflow here, so this patch adds an
upper limit to rpm to prevent that. Jean Delvare helped me with this
patch.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Roger Lucas <vt8231@hiddenengine.co.uk>
Cc: stable@vger.kernel.org
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to '')
-rw-r--r-- | drivers/hwmon/vt8231.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c index 0e7017841f7d..aee14e2192f8 100644 --- a/drivers/hwmon/vt8231.c +++ b/drivers/hwmon/vt8231.c @@ -145,7 +145,7 @@ static const u8 regtempmin[] = { 0x3a, 0x3e, 0x2c, 0x2e, 0x30, 0x32 }; */ static inline u8 FAN_TO_REG(long rpm, int div) { - if (rpm == 0) + if (rpm <= 0 || rpm > 1310720) return 0; return clamp_val(1310720 / (rpm * div), 1, 255); } |