diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2015-11-27 14:55:56 +0100 |
---|---|---|
committer | Jiri Slaby <jslaby@suse.cz> | 2016-02-24 10:23:33 +0100 |
commit | 8506cf1df5369bd1eec433a1396dc88c87877852 (patch) | |
tree | 4a0af014761219d15869286cb834ffdb4e9854cf | |
parent | 3a9194b1b662ec675d8cc61d4347e586d3d435cb (diff) | |
download | lwn-8506cf1df5369bd1eec433a1396dc88c87877852.tar.gz lwn-8506cf1df5369bd1eec433a1396dc88c87877852.zip |
iio: adis_buffer: Fix out-of-bounds memory access
commit d590faf9e8f8509a0a0aa79c38e87fcc6b913248 upstream.
The SPI tx and rx buffers are both supposed to be scan_bytes amount of
bytes large and a common allocation is used to allocate both buffers. This
puts the beginning of the tx buffer scan_bytes bytes after the rx buffer.
The initialization of the tx buffer pointer is done adding scan_bytes to
the beginning of the rx buffer, but since the rx buffer is of type __be16
this will actually add two times as much and the tx buffer ends up pointing
after the allocated buffer.
Fix this by using scan_count, which is scan_bytes / 2, instead of
scan_bytes when initializing the tx buffer pointer.
Fixes: aacff892cbd5 ("staging:iio:adis: Preallocate transfer message")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
-rw-r--r-- | drivers/iio/imu/adis_buffer.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iio/imu/adis_buffer.c b/drivers/iio/imu/adis_buffer.c index 99d8e0b0dd34..d0538bcdc1b8 100644 --- a/drivers/iio/imu/adis_buffer.c +++ b/drivers/iio/imu/adis_buffer.c @@ -43,7 +43,7 @@ int adis_update_scan_mode(struct iio_dev *indio_dev, return -ENOMEM; rx = adis->buffer; - tx = rx + indio_dev->scan_bytes; + tx = rx + scan_count; spi_message_init(&adis->msg); |