summaryrefslogtreecommitdiffstats
path: root/drivers/iio/adc
diff options
context:
space:
mode:
authorMatthias Kaehlcke <mka@chromium.org>2018-08-27 23:14:53 +0200
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2018-09-02 19:52:04 +0200
commit1e46774fec4b54adbd7cc15f1931e9df98664530 (patch)
treeda285d24b61eeb631ae9aa96557f0e5def4a0757 /drivers/iio/adc
parentiio: fix position relative kernel version (diff)
downloadlinux-1e46774fec4b54adbd7cc15f1931e9df98664530.tar.xz
linux-1e46774fec4b54adbd7cc15f1931e9df98664530.zip
iio: adc: qcom-spmi-adc5: Verify channel numbers from DT
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>
Diffstat (limited to 'drivers/iio/adc')
-rw-r--r--drivers/iio/adc/qcom-spmi-adc5.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/iio/adc/qcom-spmi-adc5.c b/drivers/iio/adc/qcom-spmi-adc5.c
index 1f9298a5c83d..f9af6b082916 100644
--- a/drivers/iio/adc/qcom-spmi-adc5.c
+++ b/drivers/iio/adc/qcom-spmi-adc5.c
@@ -519,7 +519,8 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
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;
}