From: Matthew Garrett <mjg@redhat.com>
To: guenter.roeck@ericsson.com
Cc: rydberg@euromail.se, linux-kernel@vger.kernel.org,
lm-sensors@lm-sensors.org, Matthew Garrett <mjg@redhat.com>
Subject: [PATCH 2/2 V3] applesmc: Perform some more sanity checking on temperatures
Date: Fri, 17 Dec 2010 17:24:21 -0500 [thread overview]
Message-ID: <1292624661-32474-2-git-send-email-mjg@redhat.com> (raw)
In-Reply-To: <20101217221618.GA13207@ericsson.com>
It seems that the two-byte temperature format is intended to be signed
("sp78" appears to mean "signed, decimal point, 7 bits before, 8 bits
after") and it doesn't seem terribly plausible that we'll get any of these
machines below freezing. It's probably more reasonable to assume that
negative values indicate errors and drop them.
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 851a685..411a627 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -744,6 +744,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.3.3
next prev parent reply other threads:[~2010-12-17 22:28 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-16 15:33 [PATCH 1/2] applesmc: Use PnP rather than hardcoding resources and devices Matthew Garrett
2010-12-16 15:33 ` [PATCH 2/2] applesmc: Perform some more sanity checking on temperatures Matthew Garrett
2010-12-16 16:48 ` [PATCH 1/2] applesmc: Use PnP rather than hardcoding resources and devices Henrik Rydberg
2010-12-16 17:00 ` Matthew Garrett
2010-12-16 17:00 ` [lm-sensors] " Guenter Roeck
2010-12-17 21:57 ` Matthew Garrett
2010-12-17 21:58 ` Matthew Garrett
2010-12-17 22:16 ` Guenter Roeck
2010-12-17 22:22 ` Matthew Garrett
2010-12-17 22:24 ` [PATCH 1/2 V3] " Matthew Garrett
2010-12-18 4:23 ` Guenter Roeck
2010-12-18 9:07 ` Henrik Rydberg
2010-12-18 14:40 ` Matthew Garrett
2010-12-18 15:31 ` Henrik Rydberg
2010-12-18 9:37 ` Henrik Rydberg
2010-12-18 10:09 ` [lm-sensors] " Jean Delvare
2010-12-18 10:31 ` Henrik Rydberg
2010-12-18 11:29 ` Julien BLACHE
2010-12-18 11:57 ` Henrik Rydberg
2010-12-20 13:44 ` Mikael Ström
2010-12-20 13:57 ` Jean Delvare
2010-12-20 14:23 ` Henrik Rydberg
2010-12-20 14:28 ` Matthew Garrett
2010-12-20 15:06 ` Henrik Rydberg
2010-12-20 15:12 ` Matthew Garrett
2010-12-20 15:37 ` Henrik Rydberg
2010-12-20 14:00 ` Matthew Garrett
2010-12-21 6:04 ` Mikael Ström
2010-12-21 11:09 ` Julien BLACHE
2010-12-18 14:43 ` Matthew Garrett
2010-12-18 15:30 ` Henrik Rydberg
2010-12-18 15:39 ` Matthew Garrett
2010-12-17 22:24 ` Matthew Garrett [this message]
2010-12-17 21:58 ` [PATCH 2/2] applesmc: Perform some more sanity checking on temperatures Matthew Garrett
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1292624661-32474-2-git-send-email-mjg@redhat.com \
--to=mjg@redhat.com \
--cc=guenter.roeck@ericsson.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lm-sensors@lm-sensors.org \
--cc=rydberg@euromail.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome