iio: imu: inv_mpu6050: fix possible deadlock between mutex and iio
authorJean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Mon, 30 Apr 2018 10:14:09 +0000 (12:14 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 6 May 2018 16:53:32 +0000 (17:53 +0100)
commitca4c8fc97e669d7464a95e006d0ca4eadfa4e4bc
tree3de42f737db4db863967a4e868f2650bc7d4a98f
parent3b37c41f0e56aff080d7a5a7f2adae34faa5a325
iio: imu: inv_mpu6050: fix possible deadlock between mutex and iio

Detected by kernel circular locking dependency checker.

We are locking iio mutex (iio_device_claim_direct_mode) after
locking our internal mutex. But when the buffer starts, iio first
locks its mutex and then we lock our internal one.

To avoid possible deadlock, we need to use the same order
everwhere. So we change the ordering by locking first iio mutex,
then our internal mutex.

Fixes: 68cd6e5b206b ("iio: imu: inv_mpu6050: fix lock issues by using our own mutex")
Cc: stable@vger.kernel.org
Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c