iio: dac: fix off-by-one comparison and out-of-bounds write
Subsystems (2)
PATCH 1/1 iio: dac: fix off-by-one comparison and out-of-bounds write
From: Colin Ian King <[email protected]>
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 <[email protected]>
--- drivers/iio/dac/ad5592r-base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/dac/ad5592r-base.c +1 -1
@@ -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" , ®); -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);
Signature · 1 line
2.8.1
Quoted 6 lines · Colin King
From: Colin Ian King <[email protected]>
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 <[email protected]>
Quoted 18 lines
--- drivers/iio/dac/ad5592r-base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/dac/ad5592r-base.c +1
-1@@ -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" , ®); -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);
Signature · 7 lines
Greetings, Michael -- Analog Devices GmbH Otl-Aicher Strasse 60-64 80807 München Sitz der Gesellschaft München, Registergericht München HRB 40368, Geschäftsführer: Peter Kolberg, Ali Raza Husain, Eileen Wynne
Jonathan Cameron
maintainerQuoted 9 lines · Michael Hennerich
Quoted 6 lines · Colin King
From: Colin Ian King <[email protected]>
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 <[email protected]>
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
Quoted 21 lines
Quoted 19 lines
--- drivers/iio/dac/ad5592r-base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/dac/ad5592r-base.c +1
-1@@ -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" , ®); -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);