Browse Source

drivers: dac: dacx3608: Fix bad shift operation

The parameter provided to the `BIT()` macro must be checked so that
the shift operation does not overflow the variable.

Fixes #81990

Signed-off-by: Martin Jäger <martin@libre.solar>
pull/83638/head
Martin Jäger 7 months ago committed by Benjamin Cabé
parent
commit
075cb211e5
  1. 3
      drivers/dac/dac_dacx3608.c

3
drivers/dac/dac_dacx3608.c

@ -146,7 +146,8 @@ static int dacx3608_write_value(const struct device *dev, uint8_t channel, @@ -146,7 +146,8 @@ static int dacx3608_write_value(const struct device *dev, uint8_t channel,
* Check if channel is initialized
* If broadcast channel is used, check if any channel is initialized
*/
if ((brdcast && !data->configured) || (!(data->configured & BIT(channel)))) {
if ((brdcast && !data->configured) ||
(channel < DACX3608_MAX_CHANNEL && !(data->configured & BIT(channel)))) {
LOG_ERR("Channel %d not initialized", channel);
return -EINVAL;
}

Loading…
Cancel
Save