* [PATCH] iio: adc: qcom-spmi-adc5: Verify channel numbers from DT
@ 2018-08-27 21:14 Matthias Kaehlcke
2018-09-02 17:52 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Matthias Kaehlcke @ 2018-08-27 21:14 UTC (permalink / raw)
To: Jonathan Cameron, Hartmut Knaack, Peter Meerwald-Stadler,
Siddartha Mohanadoss
Cc: linux-iio, linux-kernel, Douglas Anderson, Matthias Kaehlcke
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>
---
drivers/iio/adc/qcom-spmi-adc5.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/adc/qcom-spmi-adc5.c b/drivers/iio/adc/qcom-spmi-adc5.c
index 9c8e6f9e8248..ab5bec917c0a 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;
}
--
2.19.0.rc0.228.g281dcd1b4d0-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: adc: qcom-spmi-adc5: Verify channel numbers from DT
2018-08-27 21:14 [PATCH] iio: adc: qcom-spmi-adc5: Verify channel numbers from DT Matthias Kaehlcke
@ 2018-09-02 17:52 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2018-09-02 17:52 UTC (permalink / raw)
To: Matthias Kaehlcke
Cc: Hartmut Knaack, Peter Meerwald-Stadler, Siddartha Mohanadoss,
linux-iio, linux-kernel, Douglas Anderson
On Mon, 27 Aug 2018 14:14:53 -0700
Matthias Kaehlcke <mka@chromium.org> wrote:
> 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>
Applied to the togreg branch of iio.git and pushed out as testing for the
autobuilders to play with it.
Thanks for tidying this up.
Jonathan
> ---
> drivers/iio/adc/qcom-spmi-adc5.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/qcom-spmi-adc5.c b/drivers/iio/adc/qcom-spmi-adc5.c
> index 9c8e6f9e8248..ab5bec917c0a 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;
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-09-02 22:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-27 21:14 [PATCH] iio: adc: qcom-spmi-adc5: Verify channel numbers from DT Matthias Kaehlcke
2018-09-02 17:52 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).