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>] [day] [month] [year] [list]
Message-ID: <8760yo4x6x.wl%kuninori.morimoto.gx@renesas.com>
Date:	Wed, 20 Jan 2016 05:53:20 +0000
From:	Kuninori Morimoto <kuninori.morimoto.gx@...esas.com>
To:	Eduardo Valentin <edubezval@...il.com>
CC:	Zhang Rui <rui.zhang@...el.com>, Simon <horms@...ge.net.au>,
	Magnus <magnus.damm@...il.com>,
	Linux-Kernel <linux-kernel@...r.kernel.org>
Subject: [PATCH] thermal: of-thermal: return -EAGAIN until thermal_zone_of_sensor_register() was called

From: Kuninori Morimoto <kuninori.morimoto.gx@...esas.com>

of_parse_thermal_zones() will call thermal_zone_device_register(), and it
calls thermal_zone_get_temp() before calling thermal_zone_of_sensor_register()
which setup .get_temp on thermal_zone_of_add_sensor.
Because of this setting path, thermal_zone_device_register() will call
.get_temp and it gets -EINVAL from thermal_zone_get_temp().
Thus, kernel always indicates

        thermal thermal_zone0: failed to read out thermal zone (-22)

This patch solves this issue.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@...esas.com>
---
 drivers/thermal/of-thermal.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index 440ea63..729e2d4 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -89,6 +89,15 @@ struct __thermal_zone {
 };
 
 /***   DT thermal zone device callbacks   ***/
+static int of_thermal_null_get_temp(struct thermal_zone_device *tz,
+				       int *temp)
+{
+	/*
+	 * This function will be replaced with
+	 * of_thermal_get_temp() by thermal_zone_of_add_sensor()
+	 */
+	return -EAGAIN;
+}
 
 static int of_thermal_get_temp(struct thermal_zone_device *tz,
 			       int *temp)
@@ -383,6 +392,7 @@ static struct thermal_zone_device_ops of_thermal_ops = {
 	.get_mode = of_thermal_get_mode,
 	.set_mode = of_thermal_set_mode,
 
+	.get_temp      = of_thermal_null_get_temp,
 	.get_trip_type = of_thermal_get_trip_type,
 	.get_trip_temp = of_thermal_get_trip_temp,
 	.set_trip_temp = of_thermal_set_trip_temp,
@@ -549,7 +559,7 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
 		return;
 
 	mutex_lock(&tzd->lock);
-	tzd->ops->get_temp = NULL;
+	tzd->ops->get_temp = of_thermal_null_get_temp;
 	tzd->ops->get_trend = NULL;
 	tzd->ops->set_emul_temp = NULL;
 
-- 
1.9.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ