* [PATCH] thermal_sys: check get_temp return value
@ 2009-08-02 12:06 Michael Brunner
2009-08-03 1:07 ` Zhang Rui
0 siblings, 1 reply; 2+ messages in thread
From: Michael Brunner @ 2009-08-02 12:06 UTC (permalink / raw)
To: rui.zhang, linux-acpi; +Cc: linux-kernel
The return value of the get_temp function is not checked when doing a
thermal zone update. This may lead to a critical shutdown if get_temp
fails and the content of the temp variable is incorrectly set higher
than the critical trip point.
This has been observed on a system with incorrect ACPI implementation
where the corresponding methods were not serialized and therefore
sometimes triggered ACPI errors (AE_ALREADY_EXISTS). The following
critical shutdowns indicated a temperature of 2097 C, which was
obviously wrong.
The patch adds a return value check that jumps over all trip point
evaluations printing a warning if get_temp fails. The trip points are
evaluated again on the next polling interval with successful get_temp
execution.
Signed-off-by: Michael Brunner <mibru@gmx.de>
---
drivers/thermal/thermal_sys.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index 0a69672..4e83c29 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -953,7 +953,12 @@ void thermal_zone_device_update(struct thermal_zone_device *tz)
mutex_lock(&tz->lock);
- tz->ops->get_temp(tz, &temp);
+ if (tz->ops->get_temp(tz, &temp)) {
+ /* get_temp failed - retry it later */
+ printk(KERN_WARNING PREFIX "failed to read out thermal zone "
+ "%d\n", tz->id);
+ goto leave;
+ }
for (count = 0; count < tz->trips; count++) {
tz->ops->get_trip_type(tz, count, &trip_type);
@@ -1005,6 +1010,8 @@ void thermal_zone_device_update(struct thermal_zone_device *tz)
THERMAL_TRIPS_NONE);
tz->last_temperature = temp;
+
+ leave:
if (tz->passive)
thermal_zone_device_set_polling(tz, tz->passive_delay);
else if (tz->polling_delay)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] thermal_sys: check get_temp return value
2009-08-02 12:06 [PATCH] thermal_sys: check get_temp return value Michael Brunner
@ 2009-08-03 1:07 ` Zhang Rui
0 siblings, 0 replies; 2+ messages in thread
From: Zhang Rui @ 2009-08-03 1:07 UTC (permalink / raw)
To: Michael Brunner; +Cc: linux-acpi, linux-kernel
On Sun, 2009-08-02 at 20:06 +0800, Michael Brunner wrote:
> The return value of the get_temp function is not checked when doing a
> thermal zone update. This may lead to a critical shutdown if get_temp
> fails and the content of the temp variable is incorrectly set higher
> than the critical trip point.
> This has been observed on a system with incorrect ACPI implementation
> where the corresponding methods were not serialized and therefore
> sometimes triggered ACPI errors (AE_ALREADY_EXISTS). The following
> critical shutdowns indicated a temperature of 2097 C, which was
> obviously wrong.
>
> The patch adds a return value check that jumps over all trip point
> evaluations printing a warning if get_temp fails. The trip points are
> evaluated again on the next polling interval with successful get_temp
> execution.
>
> Signed-off-by: Michael Brunner <mibru@gmx.de>
>
good catch, Michael. :)
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> ---
>
> drivers/thermal/thermal_sys.c | 9 ++++++++-
> 1 files changed, 8 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
> index 0a69672..4e83c29 100644
> --- a/drivers/thermal/thermal_sys.c
> +++ b/drivers/thermal/thermal_sys.c
> @@ -953,7 +953,12 @@ void thermal_zone_device_update(struct thermal_zone_device *tz)
>
> mutex_lock(&tz->lock);
>
> - tz->ops->get_temp(tz, &temp);
> + if (tz->ops->get_temp(tz, &temp)) {
> + /* get_temp failed - retry it later */
> + printk(KERN_WARNING PREFIX "failed to read out thermal zone "
> + "%d\n", tz->id);
> + goto leave;
> + }
>
> for (count = 0; count < tz->trips; count++) {
> tz->ops->get_trip_type(tz, count, &trip_type);
> @@ -1005,6 +1010,8 @@ void thermal_zone_device_update(struct thermal_zone_device *tz)
> THERMAL_TRIPS_NONE);
>
> tz->last_temperature = temp;
> +
> + leave:
> if (tz->passive)
> thermal_zone_device_set_polling(tz, tz->passive_delay);
> else if (tz->polling_delay)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-08-03 1:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-02 12:06 [PATCH] thermal_sys: check get_temp return value Michael Brunner
2009-08-03 1:07 ` Zhang Rui
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.