Re: [PATCH] iio: imu: st_lsm6dsx: Fix reading array out of bounds

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 9, 2020 at 12:00 PM Alexandre Bard
<alexandre.bard@xxxxxxxxxxxxx> wrote:
>
> Former code was iterating through all possible IDs whereas only a few
> per settings array are really available. Leading to several out of
> bounds readings.
>
> Line is now longer than 80 characters. But since it is a classic for
> loop I think it is better to keep it like this than splitting it.

Agree.

Reviewed-by: Andy Shevchenko <andy.shevchenko@xxxxxxxxx>

> Signed-off-by: Alexandre Bard <alexandre.bard@xxxxxxxxxxxxx>
> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index 84d219ae6aee..be8882ff30eb 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -1350,7 +1350,7 @@ static int st_lsm6dsx_check_whoami(struct st_lsm6dsx_hw *hw, int id,
>         int err, i, j, data;
>
>         for (i = 0; i < ARRAY_SIZE(st_lsm6dsx_sensor_settings); i++) {
> -               for (j = 0; j < ST_LSM6DSX_MAX_ID; j++) {
> +               for (j = 0; j < ARRAY_SIZE(st_lsm6dsx_sensor_settings[i].id); j++) {
>                         if (st_lsm6dsx_sensor_settings[i].id[j].name &&
>                             id == st_lsm6dsx_sensor_settings[i].id[j].hw_id)
>                                 break;
> --
> 2.20.1
>


-- 
With Best Regards,
Andy Shevchenko



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux