diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c index 03c24b7c9cbde60b3c5c7e81d117c79468a78e45..1d7f8aff998222e3f2bbdf09ab9b9226df959cfc 100644 --- a/drivers/hwmon/applesmc.c +++ b/drivers/hwmon/applesmc.c @@ -734,13 +734,19 @@ static ssize_t applesmc_show_temperature(struct device *dev, entry = applesmc_get_entry_by_index(index); if (IS_ERR(entry)) return PTR_ERR(entry); + if (entry->len > 2) + return -EINVAL; - ret = applesmc_read_entry(entry, buffer, 2); + ret = applesmc_read_entry(entry, buffer, entry->len); if (ret) return ret; - temp = buffer[0]*1000; - temp += (buffer[1] >> 6) * 250; + if (entry->len == 2) { + temp = buffer[0] * 1000; + temp += (buffer[1] >> 6) * 250; + } else { + temp = buffer[0] * 4000; + } return snprintf(sysfsbuf, PAGE_SIZE, "%u\n", temp); }