summaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorFabrice Gasnier <fabrice.gasnier@st.com>2018-02-23 13:51:00 +0100
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2018-04-28 17:17:59 +0200
commitdfa105b1f602bdd63296ab0abd2c6ec2cb09eb89 (patch)
treea78e58acee0ddbe081abb08ce169549493914590 /drivers/iio
parentiio: adc: stm32-dfsdm: misc style improvements and fixes (diff)
downloadlinux-dfa105b1f602bdd63296ab0abd2c6ec2cb09eb89.tar.xz
linux-dfa105b1f602bdd63296ab0abd2c6ec2cb09eb89.zip
iio: adc: stm32-dfsdm: add check on max filter id
reg property should be checked against number of available filters. BTW, dfsdm->num_fls wasn't used. But it can be used for this purpose. This prevents using data out of allocated dfsdm->fl_list array. Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/adc/stm32-dfsdm-adc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c
index df264e042bd8..cc8ab86c1caa 100644
--- a/drivers/iio/adc/stm32-dfsdm-adc.c
+++ b/drivers/iio/adc/stm32-dfsdm-adc.c
@@ -1108,8 +1108,8 @@ static int stm32_dfsdm_adc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, adc);
ret = of_property_read_u32(dev->of_node, "reg", &adc->fl_id);
- if (ret != 0) {
- dev_err(dev, "Missing reg property\n");
+ if (ret != 0 || adc->fl_id >= adc->dfsdm->num_fls) {
+ dev_err(dev, "Missing or bad reg property\n");
return -EINVAL;
}