From: Vincent Stehlé Date: Sun, 31 Mar 2019 18:54:23 +0000 (+0200) Subject: iio: adc: ads124: avoid buffer overflow X-Git-Tag: v5.4-rc1~877^2~9^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0db8aa49a97e7f40852a64fd35abcc1292a7c365;p=platform%2Fkernel%2Flinux-rpi.git iio: adc: ads124: avoid buffer overflow 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é Reviewed-by: Mukesh Ojha Reviewed-by: Dan Murphy Cc: Signed-off-by: Jonathan Cameron --- diff --git a/drivers/iio/adc/ti-ads124s08.c b/drivers/iio/adc/ti-ads124s08.c index 53f17e4..552c2be 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)