]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 5.10
authorSasha Levin <sashal@kernel.org>
Sun, 22 Dec 2024 04:32:17 +0000 (23:32 -0500)
committerSasha Levin <sashal@kernel.org>
Sun, 22 Dec 2024 04:32:17 +0000 (23:32 -0500)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-5.10/hwmon-tmp513-fix-interpretation-of-values-of-tempera.patch [new file with mode: 0644]
queue-5.10/series

diff --git a/queue-5.10/hwmon-tmp513-fix-interpretation-of-values-of-tempera.patch b/queue-5.10/hwmon-tmp513-fix-interpretation-of-values-of-tempera.patch
new file mode 100644 (file)
index 0000000..90698ea
--- /dev/null
@@ -0,0 +1,51 @@
+From 9b8f24c1b96c78c940c0a25790da5019cbddc0c2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 16 Dec 2024 20:36:48 +0300
+Subject: hwmon: (tmp513) Fix interpretation of values of Temperature Result
+ and Limit Registers
+
+From: Murad Masimov <m.masimov@maxima.ru>
+
+[ Upstream commit dd471e25770e7e632f736b90db1e2080b2171668 ]
+
+The values returned by the driver after processing the contents of the
+Temperature Result and the Temperature Limit Registers do not correspond to
+the TMP512/TMP513 specifications. A raw register value is converted to a
+signed integer value by a sign extension in accordance with the algorithm
+provided in the specification, but due to the off-by-one error in the sign
+bit index, the result is incorrect.
+
+According to the TMP512 and TMP513 datasheets, the Temperature Result (08h
+to 0Bh) and Limit (11h to 14h) Registers are 13-bit two's complement
+integer values, shifted left by 3 bits. The value is scaled by 0.0625
+degrees Celsius per bit.  E.g., if regval = 1 1110 0111 0000 000, the
+output should be -25 degrees, but the driver will return +487 degrees.
+
+Found by Linux Verification Center (linuxtesting.org) with SVACE.
+
+Fixes: 59dfa75e5d82 ("hwmon: Add driver for Texas Instruments TMP512/513 sensor chips.")
+Signed-off-by: Murad Masimov <m.masimov@maxima.ru>
+Link: https://lore.kernel.org/r/20241216173648.526-4-m.masimov@maxima.ru
+[groeck: fixed description line length]
+Signed-off-by: Guenter Roeck <linux@roeck-us.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/hwmon/tmp513.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/hwmon/tmp513.c b/drivers/hwmon/tmp513.c
+index b9a93ee9c236..497c45d398e2 100644
+--- a/drivers/hwmon/tmp513.c
++++ b/drivers/hwmon/tmp513.c
+@@ -223,7 +223,7 @@ static int tmp51x_get_value(struct tmp51x_data *data, u8 reg, u8 pos,
+       case TMP51X_REMOTE_TEMP_LIMIT_2:
+       case TMP513_REMOTE_TEMP_LIMIT_3:
+               // 1lsb = 0.0625 degrees centigrade
+-              *val = sign_extend32(regval, 16) >> TMP51X_TEMP_SHIFT;
++              *val = sign_extend32(regval, 15) >> TMP51X_TEMP_SHIFT;
+               *val = DIV_ROUND_CLOSEST(*val * 625, 10);
+               break;
+       case TMP51X_N_FACTOR_AND_HYST_1:
+-- 
+2.39.5
+
index 1b3f3ed2a14fe255ab2d00ead5b6d58f13495dbb..d1322da7200451dbf7771dd40e214c1b9c7660b0 100644 (file)
@@ -18,3 +18,4 @@ ionic-use-ee-offset-when-returning-sprom-data.patch
 net-hinic-fix-cleanup-in-create_rxqs-txqs.patch
 net-ethernet-bgmac-platform-fix-an-of-node-reference.patch
 netfilter-ipset-fix-for-recursive-locking-warning.patch
+hwmon-tmp513-fix-interpretation-of-values-of-tempera.patch