]> git.baikalelectronics.ru Git - kernel.git/commit
iio:light:ltr501 Fix timestamp alignment issue.
authorJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 22 Jul 2020 15:50:48 +0000 (16:50 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 22 Aug 2020 10:38:58 +0000 (11:38 +0100)
commit6e365b0bc8df78702c845e9bafaabeb6632cfd27
treefc7d1d6f2f3569bcf64ba6a10d7de2cb271edaaa
parent2f1221f60d2531fa06afda9f4792136b007e3286
iio:light:ltr501 Fix timestamp alignment issue.

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.
Here we use a structure on the stack.  The driver already did an
explicit memset so no data leak was possible.

Forced alignment of ts is not strictly necessary but probably makes
the code slightly less fragile.

Note there has been some rework in this driver of the years, so no
way this will apply cleanly all the way back.

Fixes: f1d1087a8ef3 ("iio: Add Lite-On ltr501 ambient light / proximity sensor driver")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: <Stable@vger.kernel.org>
drivers/iio/light/ltr501.c