patch "iio:chemical:sps30: Fix timestamp alignment" added to staging-next
Subsystems (3)
This is a note to let you know that I've just added the patch titled
iio:chemical:sps30: Fix timestamp alignment
to my staging git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
in the staging-next branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will also be merged in the next major kernel release during the merge window.
If you have any questions about this process, please let me know.
From a5bf6fdd19c327bcfd9073a8740fa19ca4525fd4 Mon Sep 17 00:00:00 2001
From: Jonathan Cameron <[email protected]>
Date: Sun, 17 May 2020 18:29:59 +0100
Subject: iio:chemical:sps30: Fix timestamp alignment
One of a class of bugs pointed out by Lars in a recent review. iio_push_to_buffers_with_timestamp assumes the buffer used is aligned to the size of the timestamp (8 bytes). This is not guaranteed in this driver which uses an array of smaller elements on the stack.
--- drivers/iio/chemical/sps30.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/iio/chemical/sps30.c +6 -3
@@ -230,15 +230,18 @@ static irqreturn_t sps30_trigger_handler(int irq, void *p)struct iio_dev *indio_dev = pf->indio_dev;struct sps30_state *state =iio_priv (indio_dev);int ret; -s32 data[4 +2 ];/* PM1, PM2P5, PM4, PM10, timestamp */ +struct { +s32 data[4 ];/* PM1, PM2P5, PM4, PM10 */ +s64 ts; + } scan;mutex_lock (&state->lock); - ret =sps30_do_meas (state, data,4 ); + ret =sps30_do_meas (state, scan.data,ARRAY_SIZE (scan.data));mutex_unlock (&state->lock);if (ret) goto err; -iio_push_to_buffers_with_timestamp (indio_dev, data, +iio_push_to_buffers_with_timestamp (indio_dev, &scan,iio_get_time_ns (indio_dev)); err:iio_trigger_notify_done (indio_dev->trig);
Signature · 1 line
2.26.2