drivers: adc: fix underflow in lmp90xxx_adc_start_read channel check
Prevent integer underflow when sequence->channels is 0. Add an explicit check before calling find_msb_set(). Coverity CID: 487765 Signed-off-by: sudarsan N <sudarsansamy2002@gmail.com>
This commit is contained in:
parent
660d2b3e7a
commit
6d88a62417
1 changed files with 3 additions and 3 deletions
|
@ -503,9 +503,9 @@ static int lmp90xxx_adc_start_read(const struct device *dev,
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (!lmp90xxx_has_channel(dev, find_msb_set(sequence->channels) - 1)) {
|
||||
LOG_ERR("unsupported channels in mask: 0x%08x",
|
||||
sequence->channels);
|
||||
if (sequence->channels == 0 ||
|
||||
!lmp90xxx_has_channel(dev, find_msb_set(sequence->channels) - 1)) {
|
||||
LOG_ERR("unsupported channels in mask: 0x%08x", sequence->channels);
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue