aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2018-06-12 18:19:35 -0400
committerGuenter Roeck <linux@roeck-us.net>2018-06-16 19:40:36 -0400
commit91bb8f45f73f19a0150c233c0f11cdeb6d71d1e9 (patch)
tree5ba2dea6276d352c94ab8b5fb20be09083d41ad6
parent536e0019b7da4eb3badb4da5acbb70ae29e1b5ef (diff)
hwmon: (nct6775) Fix loop limit
Commit cc66b3038254 ("hwmon: (nct6775) Rework temperature source and label handling") changed a loop limit from "data->temp_label_num - 1" to "32", as part of moving from a string array to a bit mask. This results in the following error, reported by UBSAN. UBSAN: Undefined behaviour in drivers/hwmon/nct6775.c:4179:27 shift exponent 32 is too large for 32-bit type 'long unsigned int' Similar to the original loop, the limit has to be one less than the number of bits. Fixes: cc66b3038254 ("hwmon: (nct6775) Rework temperature source and label handling") Reported-by: Paul Menzel <pmenzel+linux-hwmon@molgen.mpg.de> Cc: Paul Menzel <pmenzel+linux-hwmon@molgen.mpg.de> Tested-by: Paul Menzel <pmenzel+linux-hwmon@molgen.mpg.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r--drivers/hwmon/nct6775.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
index 155d4d1d1585..f9d1349c3286 100644
--- a/drivers/hwmon/nct6775.c
+++ b/drivers/hwmon/nct6775.c
@@ -4175,7 +4175,7 @@ static int nct6775_probe(struct platform_device *pdev)
4175 * The temperature is already monitored if the respective bit in <mask> 4175 * The temperature is already monitored if the respective bit in <mask>
4176 * is set. 4176 * is set.
4177 */ 4177 */
4178 for (i = 0; i < 32; i++) { 4178 for (i = 0; i < 31; i++) {
4179 if (!(data->temp_mask & BIT(i + 1))) 4179 if (!(data->temp_mask & BIT(i + 1)))
4180 continue; 4180 continue;
4181 if (!reg_temp_alternate[i]) 4181 if (!reg_temp_alternate[i])