From patchwork Tue Dec 17 13:31:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Henriques X-Patchwork-Id: 302163 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 6E0B82C009A for ; Wed, 18 Dec 2013 00:32:38 +1100 (EST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1VsulF-0001Ko-Hu; Tue, 17 Dec 2013 13:32:33 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1VsukT-0000tY-2K for kernel-team@lists.ubuntu.com; Tue, 17 Dec 2013 13:31:45 +0000 Received: from [188.250.212.249] (helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1VsukS-0006VS-Ni; Tue, 17 Dec 2013 13:31:44 +0000 From: Luis Henriques To: Dan Carpenter Subject: [3.5.y.z extended stable] Patch "hwmon: Prevent some divide by zeros in FAN_TO_REG()" has been added to staging queue Date: Tue, 17 Dec 2013 13:31:43 +0000 Message-Id: <1387287103-28381-1-git-send-email-luis.henriques@canonical.com> X-Mailer: git-send-email 1.8.3.2 X-Extended-Stable: 3.5 Cc: Jean Delvare , kernel-team@lists.ubuntu.com, Roger Lucas X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com This is a note to let you know that I have just added a patch titled hwmon: Prevent some divide by zeros in FAN_TO_REG() to the linux-3.5.y-queue branch of the 3.5.y.z extended stable tree which can be found at: http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.5.y-queue If you, or anyone else, feels it should not be added to this tree, please reply to this email. For more information about the 3.5.y.z tree, see https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable Thanks. -Luis ------ From 777e188a83b2f8e5b38e61e9cad6ddf0678eeb9a Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 12 Dec 2013 08:05:33 +0100 Subject: hwmon: Prevent some divide by zeros in FAN_TO_REG() commit 3806b45ba4655147a011df03242cc197ab986c43 upstream. 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 Acked-by: Roger Lucas Signed-off-by: Jean Delvare [ luis: backported to 3.5: adjusted context ] Signed-off-by: Luis Henriques --- drivers/hwmon/lm78.c | 2 ++ drivers/hwmon/sis5595.c | 2 ++ drivers/hwmon/vt8231.c | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) -- 1.8.3.2 diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index f6bc414..8d6a133 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c @@ -94,6 +94,8 @@ static inline u8 FAN_TO_REG(long rpm, int div) { if (rpm <= 0) return 255; + if (rpm > 1350000) + return 1; return SENSORS_LIMIT((1350000 + rpm * div / 2) / (rpm * div), 1, 254); } diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c index 6c4d8eb..098489c 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 SENSORS_LIMIT((1350000 + rpm * div / 2) / (rpm * div), 1, 254); } diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c index 386a845..0a287e0 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 SENSORS_LIMIT(1310720 / (rpm * div), 1, 255); }