diff options
author | Guenter Roeck <linux@roeck-us.net> | 2013-09-11 10:35:47 -0700 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2013-10-13 16:16:25 -0700 |
commit | 45a5b3a183b43e07b7d1eaf1ef7c00fc87511b1b (patch) | |
tree | cd18bd11f2a364e49a7b736c3c19523faf4def11 /drivers/hwmon/nct6775.c | |
parent | e8ab508c27be9868411b6578507e93e02bdb8cdb (diff) |
hwmon: (nct6775) Check array index when accessing temp_offset
smatch complains about a potential out-of-bounds access to the
temp_offset array. That doesn't happen in practice, but it doesn't
hurt to add an explicit check either. This prevents potential problems
in the future (for example if the number of 'fixed' temperature
sensors is increased to add support for another chip).
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/nct6775.c')
-rw-r--r-- | drivers/hwmon/nct6775.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c index de57e0d60d23..b82fad487777 100644 --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c @@ -1457,7 +1457,8 @@ static struct nct6775_data *nct6775_update_device(struct device *dev) = nct6775_read_temp(data, data->reg_temp[j][i]); } - if (!(data->have_temp_fixed & (1 << i))) + if (i >= NUM_TEMP_FIXED || + !(data->have_temp_fixed & (1 << i))) continue; data->temp_offset[i] = nct6775_read_value(data, data->REG_TEMP_OFFSET[i]); |