Skip to content

Commit

Permalink
iio: adc: ads124: avoid buffer overflow
Browse files Browse the repository at this point in the history
When initializing the priv->data array starting from index 1, there is one
less element to consider than when initializing the full array.

Fixes: e717f8c ("iio: adc: Add the TI ads124s08 ADC code")
Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net>
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>
Reviewed-by: Dan Murphy <dmurphy@ti.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
  • Loading branch information
Vincent Stehlé authored and Jonathan Cameron committed Apr 7, 2019
1 parent 4e63ed6 commit 0db8aa4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/iio/adc/ti-ads124s08.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0db8aa4

Please sign in to comment.