Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1e46774f authored by Matthias Kaehlcke's avatar Matthias Kaehlcke Committed by Jonathan Cameron
Browse files

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: default avatarMatthias Kaehlcke <mka@chromium.org>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 21eab786
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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;
	}