linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] iio: dac: ad5592r: Off by one bug in ad5592r_alloc_channels()
@ 2016-04-29  9:03 Dan Carpenter
  2016-05-01 19:04 ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2016-04-29  9:03 UTC (permalink / raw)
  To: Lars-Peter Clausen
  Cc: Michael Hennerich, Jonathan Cameron, Hartmut Knaack,
	Peter Meerwald-Stadler, linux-iio, linux-kernel, kernel-janitors

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

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

end of thread, other threads:[~2016-05-04 14:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-29  9:03 [patch] iio: dac: ad5592r: Off by one bug in ad5592r_alloc_channels() Dan Carpenter
2016-05-01 19:04 ` Jonathan Cameron
2016-05-04  9:53   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).