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:
Benjamin Cabé 2025-06-09 15:16:48 +02:00 committed by Benjamin Cabé
commit 25dc5fe968

View file

@ -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;
}