Skip to content

Commit

Permalink
drivers: dac: dac_ad56xx: Fix channel range check
Browse files Browse the repository at this point in the history
An off by one error in the channel range check results in an out of
bound access to the channel lookup array.

Signed-off-by: Brett Witherspoon <[email protected]>
  • Loading branch information
bwitherspoon authored and nashif committed Jul 9, 2024
1 parent 35c7cd2 commit 97190d7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/dac/dac_ad56xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static int ad56xx_write_value(const struct device *dev, uint8_t channel, uint32_
return -EINVAL;
}

if (channel > config->channel_count) {
if (channel >= config->channel_count) {
LOG_ERR("invalid channel %i", channel);
return -EINVAL;
}
Expand Down

0 comments on commit 97190d7

Please sign in to comment.