summaryrefslogtreecommitdiff
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorMurad Masimov <m.masimov@maxima.ru>2024-11-21 20:36:03 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-12-09 12:32:30 +0300
commit40be5b4c0c1560d270c27e8cb10425fbb4a73d02 (patch)
tree20f4a566729d5deeb788419c55d5c11d94c3e4be /drivers/hwmon
parent1dfc79bfc544ff66ab6a4401f3c45f996e2576b4 (diff)
downloadlinux-40be5b4c0c1560d270c27e8cb10425fbb4a73d02.tar.xz
hwmon: (tps23861) Fix reporting of negative temperatures
[ Upstream commit de2bf507fabba9c0c678cf5ed54beb546f5ca29a ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/tps23861.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/hwmon/tps23861.c b/drivers/hwmon/tps23861.c
index d33ecbac00d6..cea34fb9ba58 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;
}