lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 14 Sep 2017 16:19:27 -0700
From:   Markus Mayer <code@...yer.net>
To:     Zhang Rui <rui.zhang@...el.com>,
        Eduardo Valentin <edubezval@...il.com>,
        Doug Berger <opendmb@...il.com>,
        Brian Norris <computersforpeace@...il.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        Dan Carpenter <dan.carpenter@...cle.com>,
        Colin King <colin.king@...onical.com>
Cc:     Markus Mayer <mmayer@...adcom.com>,
        Power Management List <linux-pm@...r.kernel.org>,
        ARM Kernel List <linux-arm-kernel@...ts.infradead.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: [PATCH] thermal: brcmstb: disable trip points properly when needed

From: Markus Mayer <mmayer@...adcom.com>

The code checking for low and high temperature points was still based
on an earlier implementation of the driver. It wasn't working properly
with the data types currently being used.

We fix this by disabling the high trip point if our high temperature is
INT_MAX and disabling the low trip point if our low temperature is -INT_MAX
(or lower).

Signed-off-by: Markus Mayer <mmayer@...adcom.com>
---

Here is my patch for the issue described. Please let me know if I should be
squashing this into the driver patch and re-submit the entire series.

 drivers/thermal/broadcom/brcmstb_thermal.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/thermal/broadcom/brcmstb_thermal.c b/drivers/thermal/broadcom/brcmstb_thermal.c
index 87b8e7a..1919f91 100644
--- a/drivers/thermal/broadcom/brcmstb_thermal.c
+++ b/drivers/thermal/broadcom/brcmstb_thermal.c
@@ -277,22 +277,23 @@ static int brcmstb_set_trips(void *data, int low, int high)
 
 	dev_dbg(priv->dev, "set trips %d <--> %d\n", low, high);
 
-	if (low) {
-		if (low > INT_MAX)
-			low = INT_MAX;
+	/*
+	 * Disable low-temp if "low" is too small. As per thermal framework
+	 * API, we use -INT_MAX rather than INT_MIN.
+	 */
+	if (low <= -INT_MAX) {
+		avs_tmon_trip_enable(priv, TMON_TRIP_TYPE_LOW, 0);
+	} else {
 		avs_tmon_set_trip_temp(priv, TMON_TRIP_TYPE_LOW, low);
 		avs_tmon_trip_enable(priv, TMON_TRIP_TYPE_LOW, 1);
-	} else {
-		avs_tmon_trip_enable(priv, TMON_TRIP_TYPE_LOW, 0);
 	}
 
-	if (high < ULONG_MAX) {
-		if (high > INT_MAX)
-			high = INT_MAX;
+	/* Disable high-temp if "high" is too big. */
+	if (high == INT_MAX) {
+		avs_tmon_trip_enable(priv, TMON_TRIP_TYPE_HIGH, 0);
+	} else {
 		avs_tmon_set_trip_temp(priv, TMON_TRIP_TYPE_HIGH, high);
 		avs_tmon_trip_enable(priv, TMON_TRIP_TYPE_HIGH, 1);
-	} else {
-		avs_tmon_trip_enable(priv, TMON_TRIP_TYPE_HIGH, 0);
 	}
 
 	return 0;
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ