RE: [PATCH] iio: addac: ad74413r: fix off by one in ad74413r_parse_channel_config()

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

 



Reviewed-by: Cosmin Tanislav <cosmin.tanislav@xxxxxxxxxx>

> -----Original Message-----
> From: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> Sent: Wednesday, December 15, 2021 1:51 PM
> To: Tanislav, Cosmin <Cosmin.Tanislav@xxxxxxxxxx>
> Cc: Hennerich, Michael <Michael.Hennerich@xxxxxxxxxx>; Jonathan
> Cameron <jic23@xxxxxxxxxx>; Linus Walleij <linus.walleij@xxxxxxxxxx>; linux-
> iio@xxxxxxxxxxxxxxx; kernel-janitors@xxxxxxxxxxxxxxx
> Subject: [PATCH] iio: addac: ad74413r: fix off by one in
> ad74413r_parse_channel_config()
> 
> [External]
> 
> The > needs to be >= to prevent accessing one element beyond the end of
> the st->channel_configs[] array.
> 
> Fixes: fea251b6a5db ("iio: addac: add AD74413R driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> ---
> Obligatory grumble:  When you merge a new driver please use a patch
> prefix based on what the driver will use.
> 
>  Bad: [SUBJECT] subsystem: add new driver for XYZ123
> Good: [SUBJECT] subsystem/xyz123: add new driver for XYZ123
> 
> Same rule for adding subdirectories.  That way no one (me) has to guess.
> 
>  drivers/iio/addac/ad74413r.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c
> index cbd9aa9b399a..289d254943e1 100644
> --- a/drivers/iio/addac/ad74413r.c
> +++ b/drivers/iio/addac/ad74413r.c
> @@ -1150,7 +1150,7 @@ static int ad74413r_parse_channel_config(struct
> iio_dev *indio_dev,
>  		return ret;
>  	}
> 
> -	if (index > AD74413R_CHANNEL_MAX) {
> +	if (index >= AD74413R_CHANNEL_MAX) {
>  		dev_err(st->dev, "Channel index %u is too large\n", index);
>  		return -EINVAL;
>  	}
> --
> 2.20.1




[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