summaryrefslogtreecommitdiff
path: root/drivers/hwmon/sis5595.c
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2013-12-12 11:05:33 +0400
committerJean Delvare <khali@endymion.delvare>2013-12-12 11:05:33 +0400
commit3806b45ba4655147a011df03242cc197ab986c43 (patch)
tree6f16fdaab2125caf51cd1c9b2fb9cd9e1eb3674f /drivers/hwmon/sis5595.c
parent33a7ab91d509fa33b4bcd3ce0038cc80298050da (diff)
downloadlinux-3806b45ba4655147a011df03242cc197ab986c43.tar.xz
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 'drivers/hwmon/sis5595.c')
-rw-r--r--drivers/hwmon/sis5595.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c
index 1404e6319deb..72a889702f0d 100644
--- a/drivers/hwmon/sis5595.c
+++ b/drivers/hwmon/sis5595.c
@@ -141,6 +141,8 @@ static inline u8 FAN_TO_REG(long rpm, int div)
{
if (rpm <= 0)
return 255;
+ if (rpm > 1350000)
+ return 1;
return clamp_val((1350000 + rpm * div / 2) / (rpm * div), 1, 254);
}