]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
iio: gyro: mpu3050-core: fix pm_runtime error handling
authorAntoniu Miclaus <antoniu.miclaus@analog.com>
Mon, 16 Feb 2026 09:57:56 +0000 (11:57 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Mar 2026 15:15:30 +0000 (16:15 +0100)
commit7a3dec5b265cf87678b10c98a72a435a8e769bb7
tree7913b08abde235ac45fa34b070622fad93e6573e
parent8f4454d47233cf33290348ddbeb4a6655ee589ec
iio: gyro: mpu3050-core: fix pm_runtime error handling

commit acc3949aab3e8094641a9c7c2768de1958c88378 upstream.

The return value of pm_runtime_get_sync() is not checked, allowing
the driver to access hardware that may fail to resume. The device
usage count is also unconditionally incremented. Use
pm_runtime_resume_and_get() which propagates errors and avoids
incrementing the usage count on failure.

In preenable, add pm_runtime_put_autosuspend() on set_8khz_samplerate()
failure since postdisable does not run when preenable fails.

Fixes: 3904b28efb2c ("iio: gyro: Add driver for the MPU-3050 gyroscope")
Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
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/gyro/mpu3050-core.c