All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: addac: ad74413r: fix off by one in ad74413r_parse_channel_config()
@ 2021-12-15 11:50 Dan Carpenter
  2021-12-16 10:50 ` Tanislav, Cosmin
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2021-12-15 11:50 UTC (permalink / raw)
  To: Cosmin Tanislav
  Cc: Michael Hennerich, Jonathan Cameron, Linus Walleij, linux-iio,
	kernel-janitors

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@oracle.com>
---
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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH] iio: addac: ad74413r: fix off by one in ad74413r_parse_channel_config()
  2021-12-15 11:50 [PATCH] iio: addac: ad74413r: fix off by one in ad74413r_parse_channel_config() Dan Carpenter
@ 2021-12-16 10:50 ` Tanislav, Cosmin
  2021-12-16 12:30   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Tanislav, Cosmin @ 2021-12-16 10:50 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Hennerich, Michael, Jonathan Cameron, Linus Walleij, linux-iio,
	kernel-janitors

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

> -----Original Message-----
> From: Dan Carpenter <dan.carpenter@oracle.com>
> Sent: Wednesday, December 15, 2021 1:51 PM
> To: Tanislav, Cosmin <Cosmin.Tanislav@analog.com>
> Cc: Hennerich, Michael <Michael.Hennerich@analog.com>; Jonathan
> Cameron <jic23@kernel.org>; Linus Walleij <linus.walleij@linaro.org>; linux-
> iio@vger.kernel.org; kernel-janitors@vger.kernel.org
> 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@oracle.com>
> ---
> 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: addac: ad74413r: fix off by one in ad74413r_parse_channel_config()
  2021-12-16 10:50 ` Tanislav, Cosmin
@ 2021-12-16 12:30   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2021-12-16 12:30 UTC (permalink / raw)
  To: Tanislav, Cosmin
  Cc: Dan Carpenter, Hennerich, Michael, Linus Walleij, linux-iio,
	kernel-janitors

On Thu, 16 Dec 2021 10:50:41 +0000
"Tanislav, Cosmin" <Cosmin.Tanislav@analog.com> wrote:

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

Applied, thanks,

Jonathan

> 
> > -----Original Message-----
> > From: Dan Carpenter <dan.carpenter@oracle.com>
> > Sent: Wednesday, December 15, 2021 1:51 PM
> > To: Tanislav, Cosmin <Cosmin.Tanislav@analog.com>
> > Cc: Hennerich, Michael <Michael.Hennerich@analog.com>; Jonathan
> > Cameron <jic23@kernel.org>; Linus Walleij <linus.walleij@linaro.org>; linux-
> > iio@vger.kernel.org; kernel-janitors@vger.kernel.org
> > 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@oracle.com>
> > ---
> > 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  
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-12-16 12:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-15 11:50 [PATCH] iio: addac: ad74413r: fix off by one in ad74413r_parse_channel_config() Dan Carpenter
2021-12-16 10:50 ` Tanislav, Cosmin
2021-12-16 12:30   ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.