Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1412092 > unrolled thread

[PATCH] iio: dac: fix off-by-one comparison and out-of-bounds write

Started byColin King <colin.king@canonical.com>
First post2016-06-02 12:10 +0200
Last post2016-06-03 14:10 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] iio: dac: fix off-by-one comparison and out-of-bounds write Colin King <colin.king@canonical.com> - 2016-06-02 12:10 +0200
    Re: [PATCH] iio: dac: fix off-by-one comparison and out-of-bounds  write Jonathan Cameron <jic23@kernel.org> - 2016-06-03 14:10 +0200

#1412092 — [PATCH] iio: dac: fix off-by-one comparison and out-of-bounds write

FromColin King <colin.king@canonical.com>
Date2016-06-02 12:10 +0200
Subject[PATCH] iio: dac: fix off-by-one comparison and out-of-bounds write
Message-ID<rFxJD-4D3-15@gated-at.bofh.it>
From: Colin Ian King <colin.king@canonical.com>

The check on reg is off-by-one, it should be >= rather than >. Fix
this to stop an out-of-bounds write to st->channel_modes[reg].

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/iio/dac/ad5592r-base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/dac/ad5592r-base.c b/drivers/iio/dac/ad5592r-base.c
index 948f600..69bde59 100644
--- a/drivers/iio/dac/ad5592r-base.c
+++ b/drivers/iio/dac/ad5592r-base.c
@@ -525,7 +525,7 @@ static int ad5592r_alloc_channels(struct ad5592r_state *st)
 
 	device_for_each_child_node(st->dev, child) {
 		ret = fwnode_property_read_u32(child, "reg", &reg);
-		if (ret || reg > ARRAY_SIZE(st->channel_modes))
+		if (ret || reg >= ARRAY_SIZE(st->channel_modes))
 			continue;
 
 		ret = fwnode_property_read_u32(child, "adi,mode", &tmp);
-- 
2.8.1

[toc] | [next] | [standalone]


#1413156 — Re: [PATCH] iio: dac: fix off-by-one comparison and out-of-bounds write

FromJonathan Cameron <jic23@kernel.org>
Date2016-06-03 14:10 +0200
SubjectRe: [PATCH] iio: dac: fix off-by-one comparison and out-of-bounds write
Message-ID<rFW5j-2Y2-1@gated-at.bofh.it>
In reply to#1412092
On 02/06/16 11:53, Michael Hennerich wrote:
> On 06/02/2016 12:06 PM, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> The check on reg is off-by-one, it should be >= rather than >. Fix
>> this to stop an out-of-bounds write to st->channel_modes[reg].
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> 
> Acked-by: Michael Hennerich <michael.hennerich@analog.com>
Already have a fix queued from the 29th of April - will push out
in the next few days.  It just managed to miss going out in the
last cycle by a few days.

Thanks,

Jonathan

> 
>> ---
>>   drivers/iio/dac/ad5592r-base.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/iio/dac/ad5592r-base.c b/drivers/iio/dac/ad5592r-base.c
>> index 948f600..69bde59 100644
>> --- a/drivers/iio/dac/ad5592r-base.c
>> +++ b/drivers/iio/dac/ad5592r-base.c
>> @@ -525,7 +525,7 @@ static int ad5592r_alloc_channels(struct ad5592r_state *st)
>>
>>       device_for_each_child_node(st->dev, child) {
>>           ret = fwnode_property_read_u32(child, "reg", &reg);
>> -        if (ret || reg > ARRAY_SIZE(st->channel_modes))
>> +        if (ret || reg >= ARRAY_SIZE(st->channel_modes))
>>               continue;
>>
>>           ret = fwnode_property_read_u32(child, "adi,mode", &tmp);
>>
> 
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web