Guenter Roeck c793279c77 hwmon: (nct6775) Fix access to fan pulse registers
Not all fans have a fan pulse register. This can result in reading
beyond the end of REG_FAN_PULSES and FAN_PULSE_SHIFT arrays,
and was reported by smatch as possible error.

1672          for (i = 0; i < ARRAY_SIZE(data->rpm); i++) {
                              ^^^^^^^^^^^^^^^^^^^^^^^^
			      This is a 7 element array.
...
1685                  data->fan_pulses[i] =
1686                    (nct6775_read_value(data, data->REG_FAN_PULSES[i])
1687                          >> data->FAN_PULSE_SHIFT[i]) & 0x03;
                                 ^^^^^^^^^^^^^^^^^^^^^^^^
				 FAN_PULSE_SHIFT is either 5 or 6
				 elements.

To fix the problem, we have to ensure that all REG_FAN_PULSES and
FAN_PULSE_SHIFT have the appropriate length, and that REG_FAN_PULSES
is only read if the register actually exists.

Fixes: 6c009501ff200 ("hwmon: (nct6775) Add support for NCT6102D/6106D")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-09-07 09:33:36 -07:00
..
2018-08-25 18:13:10 -07:00
2018-08-27 14:25:54 -06:00
2018-08-30 13:39:04 -07:00
2018-08-20 16:30:27 -07:00
2018-08-30 14:47:41 -07:00
2018-08-23 13:52:46 -07:00
2018-08-25 18:43:59 -07:00
2018-08-23 15:44:58 -07:00
2018-08-08 15:44:47 +10:00
2018-08-20 15:38:44 -07:00
2018-08-23 15:34:48 -07:00
2018-08-23 13:44:43 -07:00
2018-08-25 14:12:36 -07:00
2018-08-16 12:26:24 -07:00
2018-08-25 18:13:10 -07:00
2018-08-23 13:52:46 -07:00
2018-08-20 15:38:44 -07:00
2018-08-22 14:14:15 -07:00
2018-08-18 11:04:51 -07:00
2018-08-20 11:36:07 +02:00
2018-08-20 15:38:44 -07:00
2018-08-25 14:12:36 -07:00
2018-08-20 16:30:27 -07:00
2018-08-25 18:13:10 -07:00
2018-08-23 14:02:22 -07:00
2018-08-18 16:45:27 -07:00
2018-08-23 13:52:46 -07:00
2018-08-23 13:52:46 -07:00
2018-08-24 09:34:23 -07:00
2018-08-19 09:30:44 -07:00
2018-08-23 13:52:46 -07:00
2018-08-17 11:32:50 -07:00
2018-08-23 15:44:58 -07:00
2018-08-24 08:45:19 -07:00
2018-08-31 08:45:16 -07:00
2018-08-18 11:04:51 -07:00