Skip to content
Commit 70d97cab authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Zhang Changzhong
Browse files

iio: mma8452: Fix trigger reference couting

stable inclusion
from stable-v4.19.221
commit f5deab10ced368c807866283f8b79144c4823be8
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I9S271
CVE: CVE-2021-47500

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f5deab10ced368c807866283f8b79144c4823be8



--------------------------------

commit cd008223 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: ae6d9ce0 ("iio: mma8452: Add support for interrupt driven triggers.")
Signed-off-by: default avatarLars-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: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarZhang Changzhong <zhangchangzhong@huawei.com>
parent efdd263f
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment