linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: adc: ads124: avoid buffer overflow
@ 2019-03-31 18:54 Vincent Stehlé
  2019-04-01  8:32 ` Mukesh Ojha
  2019-04-01 12:41 ` Dan Murphy
  0 siblings, 2 replies; 5+ messages in thread
From: Vincent Stehlé @ 2019-03-31 18:54 UTC (permalink / raw)
  To: linux-iio; +Cc: linux-kernel, Vincent Stehlé, Dan Murphy, Jonathan Cameron

When initializing the priv->data array starting from index 1, there is one
less element to consider than when initializing the full array.

Fixes: e717f8c6dfec8f76 ("iio: adc: Add the TI ads124s08 ADC code")
Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net>
Cc: Dan Murphy <dmurphy@ti.com>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/adc/ti-ads124s08.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ti-ads124s08.c b/drivers/iio/adc/ti-ads124s08.c
index 53f17e4f2f230..552c2be8d87ad 100644
--- a/drivers/iio/adc/ti-ads124s08.c
+++ b/drivers/iio/adc/ti-ads124s08.c
@@ -202,7 +202,7 @@ static int ads124s_read(struct iio_dev *indio_dev, unsigned int chan)
 	};
 
 	priv->data[0] = ADS124S08_CMD_RDATA;
-	memset(&priv->data[1], ADS124S08_CMD_NOP, sizeof(priv->data));
+	memset(&priv->data[1], ADS124S08_CMD_NOP, sizeof(priv->data) - 1);
 
 	ret = spi_sync_transfer(priv->spi, t, ARRAY_SIZE(t));
 	if (ret < 0)
-- 
2.20.1


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

* Re: [PATCH] iio: adc: ads124: avoid buffer overflow
  2019-03-31 18:54 [PATCH] iio: adc: ads124: avoid buffer overflow Vincent Stehlé
@ 2019-04-01  8:32 ` Mukesh Ojha
  2019-04-01 12:41 ` Dan Murphy
  1 sibling, 0 replies; 5+ messages in thread
From: Mukesh Ojha @ 2019-04-01  8:32 UTC (permalink / raw)
  To: Vincent Stehlé, linux-iio; +Cc: linux-kernel, Dan Murphy, Jonathan Cameron


On 4/1/2019 12:24 AM, Vincent Stehlé wrote:
> When initializing the priv->data array starting from index 1, there is one
> less element to consider than when initializing the full array.
>
> Fixes: e717f8c6dfec8f76 ("iio: adc: Add the TI ads124s08 ADC code")
> Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net>
> Cc: Dan Murphy <dmurphy@ti.com>
> Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>


Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>

Cheers,
-Mukesh

> ---
>   drivers/iio/adc/ti-ads124s08.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/ti-ads124s08.c b/drivers/iio/adc/ti-ads124s08.c
> index 53f17e4f2f230..552c2be8d87ad 100644
> --- a/drivers/iio/adc/ti-ads124s08.c
> +++ b/drivers/iio/adc/ti-ads124s08.c
> @@ -202,7 +202,7 @@ static int ads124s_read(struct iio_dev *indio_dev, unsigned int chan)
>   	};
>   
>   	priv->data[0] = ADS124S08_CMD_RDATA;
> -	memset(&priv->data[1], ADS124S08_CMD_NOP, sizeof(priv->data));
> +	memset(&priv->data[1], ADS124S08_CMD_NOP, sizeof(priv->data) - 1);
>   
>   	ret = spi_sync_transfer(priv->spi, t, ARRAY_SIZE(t));
>   	if (ret < 0)

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

* Re: [PATCH] iio: adc: ads124: avoid buffer overflow
  2019-03-31 18:54 [PATCH] iio: adc: ads124: avoid buffer overflow Vincent Stehlé
  2019-04-01  8:32 ` Mukesh Ojha
@ 2019-04-01 12:41 ` Dan Murphy
  2019-04-07 12:02   ` Jonathan Cameron
  1 sibling, 1 reply; 5+ messages in thread
From: Dan Murphy @ 2019-04-01 12:41 UTC (permalink / raw)
  To: Vincent Stehlé, linux-iio; +Cc: linux-kernel, Jonathan Cameron

On 3/31/19 1:54 PM, Vincent Stehlé wrote:
> When initializing the priv->data array starting from index 1, there is one
> less element to consider than when initializing the full array.
> 
> Fixes: e717f8c6dfec8f76 ("iio: adc: Add the TI ads124s08 ADC code")
> Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net>
> Cc: Dan Murphy <dmurphy@ti.com>
> Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
>  drivers/iio/adc/ti-ads124s08.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/ti-ads124s08.c b/drivers/iio/adc/ti-ads124s08.c
> index 53f17e4f2f230..552c2be8d87ad 100644
> --- a/drivers/iio/adc/ti-ads124s08.c
> +++ b/drivers/iio/adc/ti-ads124s08.c
> @@ -202,7 +202,7 @@ static int ads124s_read(struct iio_dev *indio_dev, unsigned int chan)
>  	};
>  
>  	priv->data[0] = ADS124S08_CMD_RDATA;
> -	memset(&priv->data[1], ADS124S08_CMD_NOP, sizeof(priv->data));
> +	memset(&priv->data[1], ADS124S08_CMD_NOP, sizeof(priv->data) - 1);
>  
>  	ret = spi_sync_transfer(priv->spi, t, ARRAY_SIZE(t));
>  	if (ret < 0)
> 

Reviewed-by: Dan Murphy <dmurphy@ti.com>
-- 
------------------
Dan Murphy

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

* Re: [PATCH] iio: adc: ads124: avoid buffer overflow
  2019-04-01 12:41 ` Dan Murphy
@ 2019-04-07 12:02   ` Jonathan Cameron
  2019-04-07 12:03     ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Cameron @ 2019-04-07 12:02 UTC (permalink / raw)
  To: Dan Murphy; +Cc: Vincent Stehlé, linux-iio, linux-kernel, Jonathan Cameron

On Mon, 1 Apr 2019 07:41:37 -0500
Dan Murphy <dmurphy@ti.com> wrote:

> On 3/31/19 1:54 PM, Vincent Stehlé wrote:
> > When initializing the priv->data array starting from index 1, there is one
> > less element to consider than when initializing the full array.
> > 
> > Fixes: e717f8c6dfec8f76 ("iio: adc: Add the TI ads124s08 ADC code")
> > Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net>
> > Cc: Dan Murphy <dmurphy@ti.com>
> > Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > ---
> >  drivers/iio/adc/ti-ads124s08.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/iio/adc/ti-ads124s08.c b/drivers/iio/adc/ti-ads124s08.c
> > index 53f17e4f2f230..552c2be8d87ad 100644
> > --- a/drivers/iio/adc/ti-ads124s08.c
> > +++ b/drivers/iio/adc/ti-ads124s08.c
> > @@ -202,7 +202,7 @@ static int ads124s_read(struct iio_dev *indio_dev, unsigned int chan)
> >  	};
> >  
> >  	priv->data[0] = ADS124S08_CMD_RDATA;
> > -	memset(&priv->data[1], ADS124S08_CMD_NOP, sizeof(priv->data));
> > +	memset(&priv->data[1], ADS124S08_CMD_NOP, sizeof(priv->data) - 1);
> >  
> >  	ret = spi_sync_transfer(priv->spi, t, ARRAY_SIZE(t));
> >  	if (ret < 0)
> >   
> 
> Reviewed-by: Dan Murphy <dmurphy@ti.com>

Applied to the fixes-togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan

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

* Re: [PATCH] iio: adc: ads124: avoid buffer overflow
  2019-04-07 12:02   ` Jonathan Cameron
@ 2019-04-07 12:03     ` Jonathan Cameron
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2019-04-07 12:03 UTC (permalink / raw)
  To: Dan Murphy; +Cc: Vincent Stehlé, linux-iio, linux-kernel, Jonathan Cameron

On Sun, 7 Apr 2019 13:02:42 +0100
Jonathan Cameron <jic23@jic23.retrosnub.co.uk> wrote:

> On Mon, 1 Apr 2019 07:41:37 -0500
> Dan Murphy <dmurphy@ti.com> wrote:
> 
> > On 3/31/19 1:54 PM, Vincent Stehlé wrote:  
> > > When initializing the priv->data array starting from index 1, there is one
> > > less element to consider than when initializing the full array.
> > > 
> > > Fixes: e717f8c6dfec8f76 ("iio: adc: Add the TI ads124s08 ADC code")
> > > Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net>
> > > Cc: Dan Murphy <dmurphy@ti.com>
> > > Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > > ---
> > >  drivers/iio/adc/ti-ads124s08.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/iio/adc/ti-ads124s08.c b/drivers/iio/adc/ti-ads124s08.c
> > > index 53f17e4f2f230..552c2be8d87ad 100644
> > > --- a/drivers/iio/adc/ti-ads124s08.c
> > > +++ b/drivers/iio/adc/ti-ads124s08.c
> > > @@ -202,7 +202,7 @@ static int ads124s_read(struct iio_dev *indio_dev, unsigned int chan)
> > >  	};
> > >  
> > >  	priv->data[0] = ADS124S08_CMD_RDATA;
> > > -	memset(&priv->data[1], ADS124S08_CMD_NOP, sizeof(priv->data));
> > > +	memset(&priv->data[1], ADS124S08_CMD_NOP, sizeof(priv->data) - 1);
> > >  
> > >  	ret = spi_sync_transfer(priv->spi, t, ARRAY_SIZE(t));
> > >  	if (ret < 0)
> > >     
> > 
> > Reviewed-by: Dan Murphy <dmurphy@ti.com>  
> 
> Applied to the fixes-togreg branch of iio.git and pushed out as testing
> for the autobuilders to play with it.
Wrong finger memory. Not pushed out as testing. Pushed out as fixes-togreg!

Jonathan
> 
> Thanks,
> 
> Jonathan


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

end of thread, other threads:[~2019-04-07 12:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-31 18:54 [PATCH] iio: adc: ads124: avoid buffer overflow Vincent Stehlé
2019-04-01  8:32 ` Mukesh Ojha
2019-04-01 12:41 ` Dan Murphy
2019-04-07 12:02   ` Jonathan Cameron
2019-04-07 12:03     ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).