drivers: dac: esp32: avoid out-of-range channel ID
Fix channel ID check in dac_esp32_channel_setup as it was allowing to set up a channel with ID greater than the number of channels. Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
This commit is contained in:
parent
aa8386929e
commit
25dc5fe968
1 changed files with 1 additions and 1 deletions
|
@ -39,7 +39,7 @@ static int dac_esp32_channel_setup(const struct device *dev,
|
|||
{
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
if (channel_cfg->channel_id > SOC_DAC_CHAN_NUM) {
|
||||
if (channel_cfg->channel_id >= SOC_DAC_CHAN_NUM) {
|
||||
LOG_ERR("Channel %d is not valid", channel_cfg->channel_id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue