Skip to contentSkip to conversation

hwmon: (ads1015) Fix off-by-one for valid channel index checking

PATCH Applied Axel Lin 2 participants 3 messages Jul 30, 2014 Hardware monitoring

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 hwmon: (ads1015) Fix off-by-one for valid channel index checking

Current code uses channel as array index, so the valid channel value is 0 .. ADS1015_CHANNELS - 1.

---
 drivers/hwmon/ads1015.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/ads1015.c +1 -1
index 7f9dc2f..22e0c92 100644
@@ -198,7 +198,7 @@ static int ads1015_get_channels_config_of(struct i2c_client *client)
 		}
 
 		channel = be32_to_cpup(property);
-		if (channel > ADS1015_CHANNELS) {
+		if (channel >= ADS1015_CHANNELS) {
 			dev_err(&client->dev,
 				"invalid channel index %d on %s\n",
 				channel, node->full_name);
Signature · 9 lines
1.9.1




_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
author
#2 lore raw
In reply to Axel Lin

2014-07-30 11:28 GMT+08:00 Guenter Roeck <[email protected]>:

Quoted 9 lines · Axel Lin
Quoted 5 lines

Current code uses channel as array index, so the valid channel value is 0 .. ADS1015_CHANNELS - 1.

Amazing. How do you find this stuff ?

I just read the code. :-)

Axel

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors