iio: adc: ad7124: change setup reg allocation strategy
Hello David Lechner,
Commit 9065197e0d41 ("iio: adc: ad7124: change setup reg allocation strategy") from Sep 23, 2025 (linux-next), leads to the following Smatch static checker warning:
drivers/iio/adc/ad7124.c:595 ad7124_release_config_slot() warn: potential bounds check after use 'channel'
drivers/iio/adc/ad7124.c
587 static void ad7124_release_config_slot(struct ad7124_state *st, u8 channel)
588 {
589 unsigned int slot = st->channels[channel].cfg.cfg_slot;
^^^^^^^^^^^^^^^^^^^^^
590
591 /*
592 * All of these conditions can happen at probe when all channels are
593 * disabled. Otherwise, they should not happen normally.
594 */
--> 595 if (channel >= st->num_channels || slot == AD7124_CFG_SLOT_UNASSIGNED ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^If channel is invalid then we would already have read from out of bounds.
596 st->cfg_slot_use_count[slot] == 0)
597 return;
598
599 st->cfg_slot_use_count[slot]--;
600 st->channels[channel].cfg.cfg_slot = AD7124_CFG_SLOT_UNASSIGNED;
601 }regards,
dan carpenter