All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] [PATCH] hwmon: (ads1015) Fix off-by-one for valid channel index checking
@ 2014-07-30  3:13 Axel Lin
  2014-07-30  3:28 ` Guenter Roeck
  2014-07-30  4:30 ` Axel Lin
  0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2014-07-30  3:13 UTC (permalink / raw)
  To: lm-sensors

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

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/hwmon/ads1015.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/ads1015.c b/drivers/hwmon/ads1015.c
index 7f9dc2f..22e0c92 100644
--- a/drivers/hwmon/ads1015.c
+++ b/drivers/hwmon/ads1015.c
@@ -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);
-- 
1.9.1




_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [lm-sensors] [PATCH] hwmon: (ads1015) Fix off-by-one for valid channel index checking
  2014-07-30  3:13 [lm-sensors] [PATCH] hwmon: (ads1015) Fix off-by-one for valid channel index checking Axel Lin
@ 2014-07-30  3:28 ` Guenter Roeck
  2014-07-30  4:30 ` Axel Lin
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2014-07-30  3:28 UTC (permalink / raw)
  To: lm-sensors

On 07/29/2014 08:13 PM, Axel Lin wrote:
> Current code uses channel as array index, so the valid channel value is
> 0 .. ADS1015_CHANNELS - 1.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>

Amazing. How do you find this stuff ?

Applied.

Thanks,
Guenter


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [lm-sensors] [PATCH] hwmon: (ads1015) Fix off-by-one for valid channel index checking
  2014-07-30  3:13 [lm-sensors] [PATCH] hwmon: (ads1015) Fix off-by-one for valid channel index checking Axel Lin
  2014-07-30  3:28 ` Guenter Roeck
@ 2014-07-30  4:30 ` Axel Lin
  1 sibling, 0 replies; 3+ messages in thread
From: Axel Lin @ 2014-07-30  4:30 UTC (permalink / raw)
  To: lm-sensors

2014-07-30 11:28 GMT+08:00 Guenter Roeck <linux@roeck-us.net>:
> On 07/29/2014 08:13 PM, Axel Lin wrote:
>>
>> Current code uses channel as array index, so the valid channel value is
>> 0 .. ADS1015_CHANNELS - 1.
>>
>> Signed-off-by: Axel Lin <axel.lin@ingics.com>
>
>
> Amazing. How do you find this stuff ?
I just read the code. :-)

Axel

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-07-30  4:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-30  3:13 [lm-sensors] [PATCH] hwmon: (ads1015) Fix off-by-one for valid channel index checking Axel Lin
2014-07-30  3:28 ` Guenter Roeck
2014-07-30  4:30 ` Axel Lin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.