Skip to content

Commit ed08ebb

Browse files
committed
hwmon: (drivetemp) Return -ENODATA for invalid temperatures
Holger Hoffstätte observed that Samsung 850 Pro may return invalid temperatures for a short period of time after resume. Return -ENODATA to userspace if this is observed. Fixes: 5b46903 ("hwmon: Driver for disk and solid state drives with temperature sensors") Reported-by: Holger Hoffstätte <[email protected]> Cc: Holger Hoffstätte <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
1 parent 6bdf8f3 commit ed08ebb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/hwmon/drivetemp.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,18 @@ static int drivetemp_get_scttemp(struct drivetemp_data *st, u32 attr, long *val)
264264
return err;
265265
switch (attr) {
266266
case hwmon_temp_input:
267+
if (!temp_is_valid(buf[SCT_STATUS_TEMP]))
268+
return -ENODATA;
267269
*val = temp_from_sct(buf[SCT_STATUS_TEMP]);
268270
break;
269271
case hwmon_temp_lowest:
272+
if (!temp_is_valid(buf[SCT_STATUS_TEMP_LOWEST]))
273+
return -ENODATA;
270274
*val = temp_from_sct(buf[SCT_STATUS_TEMP_LOWEST]);
271275
break;
272276
case hwmon_temp_highest:
277+
if (!temp_is_valid(buf[SCT_STATUS_TEMP_HIGHEST]))
278+
return -ENODATA;
273279
*val = temp_from_sct(buf[SCT_STATUS_TEMP_HIGHEST]);
274280
break;
275281
default:

0 commit comments

Comments
 (0)