]> git.baikalelectronics.ru Git - kernel.git/commit
iio: mma8452: Fix trigger reference couting
authorLars-Peter Clausen <lars@metafoo.de>
Sun, 24 Oct 2021 09:26:59 +0000 (11:26 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Dec 2021 09:57:20 +0000 (10:57 +0100)
commitaf13a6cbf7456dd93557208c96c625c0481cbb2b
treead912e64eda54495f4ac905a70303a3a80d8a984
parenta029239f9dc041515fa443b66b0fe932c97ae8fa
iio: mma8452: Fix trigger reference couting

commit c818630e6ac528a93397e5399580d23b066530cd upstream.

The mma8452 driver directly assigns a trigger to the struct iio_dev. The
IIO core when done using this trigger will call `iio_trigger_put()` to drop
the reference count by 1.

Without the matching `iio_trigger_get()` in the driver the reference count
can reach 0 too early, the trigger gets freed while still in use and a
use-after-free occurs.

Fix this by getting a reference to the trigger before assigning it to the
IIO device.

Fixes: 14fd01d162a1 ("iio: mma8452: Add support for interrupt driven triggers.")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20211024092700.6844-1-lars@metafoo.de
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/accel/mma8452.c