]> git.karo-electronics.de Git - karo-tx-linux.git/commit
iio: adis_buffer: Fix out-of-bounds memory access
authorLars-Peter Clausen <lars@metafoo.de>
Fri, 27 Nov 2015 13:55:56 +0000 (14:55 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Feb 2016 20:01:17 +0000 (12:01 -0800)
commitdc275a6eb9d0ebe7711d8ced07509dc5168163b3
tree3a7698bc01d346fcc73a40a76aa88e349daf2abc
parenta258a959fcf31230ae660f5b0a537b8d7fc0b675
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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/imu/adis_buffer.c