The driver only defines a subset of all possible ADC channels. Channel
numbers read from the device tree are accepted as long as they don't
exceed a max value, even when no channel definition exists. Add a
check to abort initialization in this case.
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
return ret;
}
- if (chan > ADC5_PARALLEL_ISENSE_VBAT_IDATA) {
+ if (chan > ADC5_PARALLEL_ISENSE_VBAT_IDATA ||
+ !data->adc_chans[chan].datasheet_name) {
dev_err(dev, "%s invalid channel number %d\n", name, chan);
return -EINVAL;
}