Skip to content

Commit de2bf50

Browse files
Murad Masimovgroeck
Murad Masimov
authored andcommitted
hwmon: (tps23861) Fix reporting of negative temperatures
Negative temperatures are reported as large positive temperatures due to missing sign extension from unsigned int to long. Cast unsigned raw register values to signed before performing the calculations to fix the problem. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: fff7b8a ("hwmon: add Texas Instruments TPS23861 driver") Signed-off-by: Murad Masimov <[email protected]> Message-ID: <[email protected]> [groeck: Updated subject and description] Signed-off-by: Guenter Roeck <[email protected]>
1 parent 8281d62 commit de2bf50

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/hwmon/tps23861.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static int tps23861_read_temp(struct tps23861_data *data, long *val)
132132
if (err < 0)
133133
return err;
134134

135-
*val = (regval * TEMPERATURE_LSB) - 20000;
135+
*val = ((long)regval * TEMPERATURE_LSB) - 20000;
136136

137137
return 0;
138138
}

0 commit comments

Comments
 (0)