Skip to content

Commit dd6230b

Browse files
Colin Ian Kingjic23
authored andcommitted
iio: dac: ad5770r: fix off-by-one check on maximum number of channels
Currently there is an off-by-one check on the number of channels that will cause an arry overrun in array st->output_mode when calling the function d5770r_store_output_range. Fix this by using >= rather than > to check for maximum number of channels. Addresses-Coverity: ("Out-of-bounds access") Fixes: cbbb819 ("iio: dac: ad5770r: Add AD5770R support") Signed-off-by: Colin Ian King <[email protected]> Reviewed-by: Alexandru Ardelean <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 3a63da2 commit dd6230b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/iio/dac/ad5770r.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ static int ad5770r_channel_config(struct ad5770r_state *st)
525525
ret = fwnode_property_read_u32(child, "num", &num);
526526
if (ret)
527527
return ret;
528-
if (num > AD5770R_MAX_CHANNELS)
528+
if (num >= AD5770R_MAX_CHANNELS)
529529
return -EINVAL;
530530

531531
ret = fwnode_property_read_u32_array(child,

0 commit comments

Comments
 (0)