Skip to content

Commit

Permalink
iio: adc: ad7768-1: Fix too small buffer passed to iio_push_to_buffer…
Browse files Browse the repository at this point in the history
…s_with_timestamp()

commit a1caeeb upstream.

Add space for the timestamp to be inserted.  Also ensure correct
alignment for passing to iio_push_to_buffers_with_timestamp()

Fixes: a5f8c7d ("iio: adc: Add AD7768-1 ADC basic support")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210501165314.511954-2-jic23@kernel.org
Cc: <Stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
jic23 authored and gregkh committed Jun 3, 2021
1 parent cd9c0a1 commit a4bc913
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/iio/adc/ad7768-1.c
Expand Up @@ -167,6 +167,10 @@ struct ad7768_state {
* transfer buffers to live in their own cache lines.
*/
union {
struct {
__be32 chan;
s64 timestamp;
} scan;
__be32 d32;
u8 d8[2];
} data ____cacheline_aligned;
Expand Down Expand Up @@ -469,11 +473,11 @@ static irqreturn_t ad7768_trigger_handler(int irq, void *p)

mutex_lock(&st->lock);

ret = spi_read(st->spi, &st->data.d32, 3);
ret = spi_read(st->spi, &st->data.scan.chan, 3);
if (ret < 0)
goto err_unlock;

iio_push_to_buffers_with_timestamp(indio_dev, &st->data.d32,
iio_push_to_buffers_with_timestamp(indio_dev, &st->data.scan,
iio_get_time_ns(indio_dev));

iio_trigger_notify_done(indio_dev->trig);
Expand Down

0 comments on commit a4bc913

Please sign in to comment.