From patchwork Thu Aug 6 22:16:31 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 39696 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n76MI2GU027241 for ; Thu, 6 Aug 2009 22:18:02 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754341AbZHFWRh (ORCPT ); Thu, 6 Aug 2009 18:17:37 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754509AbZHFWRh (ORCPT ); Thu, 6 Aug 2009 18:17:37 -0400 Received: from smtp1.linux-foundation.org ([140.211.169.13]:59320 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754341AbZHFWRg (ORCPT ); Thu, 6 Aug 2009 18:17:36 -0400 Received: from imap1.linux-foundation.org (imap1.linux-foundation.org [140.211.169.55]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id n76MGW5a012319 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 6 Aug 2009 15:16:33 -0700 Received: from localhost.localdomain (localhost [127.0.0.1]) by imap1.linux-foundation.org (8.13.5.20060308/8.13.5/Debian-3ubuntu1.1) with ESMTP id n76MGVL3019360; Thu, 6 Aug 2009 15:16:32 -0700 Message-Id: <200908062216.n76MGVL3019360@imap1.linux-foundation.org> Subject: [patch for 2.6.31? 1/2] thermal_sys: check get_temp return value To: lenb@kernel.org Cc: linux-acpi@vger.kernel.org, akpm@linux-foundation.org, mibru@gmx.de, rui.zhang@intel.com From: akpm@linux-foundation.org Date: Thu, 06 Aug 2009 15:16:31 -0700 X-Spam-Status: No, hits=-3.512 required=5 tests=AWL, BAYES_00, OSDL_HEADER_SUBJECT_BRACKETED X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.13 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Michael Brunner 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 Acked-by: Zhang Rui Cc: Len Brown Signed-off-by: Andrew Morton --- drivers/thermal/thermal_sys.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff -puN drivers/thermal/thermal_sys.c~thermal_sys-check-get_temp-return-value drivers/thermal/thermal_sys.c --- a/drivers/thermal/thermal_sys.c~thermal_sys-check-get_temp-return-value +++ a/drivers/thermal/thermal_sys.c @@ -953,7 +953,12 @@ void thermal_zone_device_update(struct t 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 t 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)