• Jonathan Cameron's avatar
    iio:light:ltr501 Fix timestamp alignment issue. · 2684d500
    Jonathan Cameron authored
    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: 2690be90 ("iio: Add Lite-On ltr501 ambient light / proximity sensor driver")
    Reported-by: default avatarLars-Peter Clausen <lars@metafoo.de>
    Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
    Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
    Cc: <Stable@vger.kernel.org>
    2684d500
ltr501.c 38.3 KB