lkml.org 
[lkml]   [2018]   [Feb]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 6/7] iio: adc: stm32-dfsdm: add check on max filter id
    Date
    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>
    ---
    drivers/iio/adc/stm32-dfsdm-adc.c | 4 ++--
    1 file changed, 2 insertions(+), 2 deletions(-)

    diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c
    index 57bcb45..1b78bec 100644
    --- a/drivers/iio/adc/stm32-dfsdm-adc.c
    +++ b/drivers/iio/adc/stm32-dfsdm-adc.c
    @@ -1111,8 +1111,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;
    }

    --
    1.9.1
    \
     
     \ /
      Last update: 2018-02-23 13:52    [W:5.525 / U:0.028 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site