Skip to content

Commit 25dc5fe

Browse files
committed
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é <[email protected]>
1 parent aa83869 commit 25dc5fe

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/dac/dac_esp32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static int dac_esp32_channel_setup(const struct device *dev,
3939
{
4040
ARG_UNUSED(dev);
4141

42-
if (channel_cfg->channel_id > SOC_DAC_CHAN_NUM) {
42+
if (channel_cfg->channel_id >= SOC_DAC_CHAN_NUM) {
4343
LOG_ERR("Channel %d is not valid", channel_cfg->channel_id);
4444
return -EINVAL;
4545
}

0 commit comments

Comments
 (0)