diff options
author | Murad Masimov <m.masimov@maxima.ru> | 2024-11-21 18:36:03 +0100 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2024-11-23 18:49:03 +0100 |
commit | de2bf507fabba9c0c678cf5ed54beb546f5ca29a (patch) | |
tree | cdda0d231aee3fc25edb6d95582643abbadd6fb1 /drivers/hwmon/tps23861.c | |
parent | hwmon: (tmp108) Do not fail in I3C probe when I3C regmap is a module (diff) | |
download | linux-de2bf507fabba9c0c678cf5ed54beb546f5ca29a.tar.xz linux-de2bf507fabba9c0c678cf5ed54beb546f5ca29a.zip |
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: fff7b8ab2255 ("hwmon: add Texas Instruments TPS23861 driver")
Signed-off-by: Murad Masimov <m.masimov@maxima.ru>
Message-ID: <20241121173604.2021-1-m.masimov@maxima.ru>
[groeck: Updated subject and description]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to '')
-rw-r--r-- | drivers/hwmon/tps23861.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/hwmon/tps23861.c b/drivers/hwmon/tps23861.c index dfcfb09d9f3c..80fb03f30c30 100644 --- a/drivers/hwmon/tps23861.c +++ b/drivers/hwmon/tps23861.c @@ -132,7 +132,7 @@ static int tps23861_read_temp(struct tps23861_data *data, long *val) if (err < 0) return err; - *val = (regval * TEMPERATURE_LSB) - 20000; + *val = ((long)regval * TEMPERATURE_LSB) - 20000; return 0; } |