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


Groups > linux.kernel > #1390895

[patch] iio: dac: ad5592r: Off by one bug in ad5592r_alloc_channels()

From Dan Carpenter <dan.carpenter@oracle.com>
Newsgroups linux.kernel
Subject [patch] iio: dac: ad5592r: Off by one bug in ad5592r_alloc_channels()
Date 2016-04-29 11:10 +0200
Message-ID <rtcAV-3l0-13@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


The > here should be >= or we go beyond the end for the array.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

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);

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[patch] iio: dac: ad5592r: Off by one bug in ad5592r_alloc_channels() Dan Carpenter <dan.carpenter@oracle.com> - 2016-04-29 11:10 +0200
  Re: [patch] iio: dac: ad5592r: Off by one bug in  ad5592r_alloc_channels() Jonathan Cameron <jic23@kernel.org> - 2016-05-01 23:30 +0200
    Re: [patch] iio: dac: ad5592r: Off by one bug in  ad5592r_alloc_channels() Jonathan Cameron <jic23@kernel.org> - 2016-05-04 16:50 +0200

csiph-web