All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] [PATCH 2/3] hwmon: Fix applesmc temperature handling
@ 2011-08-09 16:14 Matthew Garrett
  2011-08-10 17:05 ` [lm-sensors] [PATCH 2/3] hwmon: Fix applesmc temperature Guenter Roeck
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Matthew Garrett @ 2011-08-09 16:14 UTC (permalink / raw)
  To: lm-sensors

The temperature registers in the applesmc hardware are signed. It's likely
that a negative value is invalid, so trigger on that and return an error
rather than an erroneous value.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
---
 drivers/hwmon/applesmc.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 62e2493..4540bb1 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -781,6 +781,10 @@ static ssize_t applesmc_show_temperature(struct device *dev,
 		return ret;
 
 	if (entry->len = 2) {
+		if (buffer[0] >= 0x80) {
+			/* The two byte format is signed - ignore negative */
+			return -EINVAL;
+		}
 		temp = buffer[0] * 1000;
 		temp += (buffer[1] >> 6) * 250;
 	} else {
-- 
1.7.6


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-08-11 19:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-09 16:14 [lm-sensors] [PATCH 2/3] hwmon: Fix applesmc temperature handling Matthew Garrett
2011-08-10 17:05 ` [lm-sensors] [PATCH 2/3] hwmon: Fix applesmc temperature Guenter Roeck
2011-08-10 17:17 ` Matthew Garrett
2011-08-10 17:41 ` Guenter Roeck
2011-08-10 17:57 ` Matthew Garrett
2011-08-11 19:36 ` Henrik Rydberg
2011-08-11 19:42 ` Matthew Garrett

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.