Skip to content

Commit 2adb3f8

Browse files
nunojsagregkh
authored andcommitted
iio: buffer: Fix demux update
commit 19ef7b7 upstream. When updating the buffer demux, we will skip a scan element from the device in the case `in_ind != out_ind` and we enter the while loop. in_ind should only be refreshed with `find_next_bit()` in the end of the loop. Note, to cause problems we need a situation where we are skippig over an element (channel not enabled) that happens to not have the same size as the next element. Whilst this is a possible situation we haven't actually identified any cases in mainline where it happens as most drivers have consistent channel storage sizes with the exception of the timestamp which is the last element and hence never skipped over. Fixes: 5ada4ea ("staging:iio: add demux optionally to path from device to buffer") Signed-off-by: Nuno Sá <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20201112144323.28887-1-nuno.sa@analog.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent aa606eb commit 2adb3f8

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎drivers/iio/industrialio-buffer.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -865,12 +865,12 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev,
865865
indio_dev->masklength,
866866
in_ind + 1);
867867
while (in_ind != out_ind) {
868-
in_ind = find_next_bit(indio_dev->active_scan_mask,
869-
indio_dev->masklength,
870-
in_ind + 1);
871868
length = iio_storage_bytes_for_si(indio_dev, in_ind);
872869
/* Make sure we are aligned */
873870
in_loc = roundup(in_loc, length) + length;
871+
in_ind = find_next_bit(indio_dev->active_scan_mask,
872+
indio_dev->masklength,
873+
in_ind + 1);
874874
}
875875
length = iio_storage_bytes_for_si(indio_dev, in_ind);
876876
out_loc = roundup(out_loc, length);

0 commit comments

Comments
 (0)