[PATCH v2] Input: cyapa - fix runtime PM leak in cyapa_update_rt_suspend_scanrate()

From: Wentao Liang

Date: Sun Nov 08 2026 - 01:45:47 EST


pm_runtime_get_sync() unconditionally increments the runtime PM usage
counter. If mutex_lock_interruptible() is interrupted, the function
returns without dropping that reference, so the usage count stays
elevated for as long as the driver is bound and the device can no longer
be autosuspended. Drop the reference on the error path.

Use pm_runtime_put_autosuspend() rather than the synchronous variant
there: nothing has been done to the device on this path, so there is
nothing to wait for, and with the 2 s autosuspend delay the driver
configures the put only arms the autosuspend timer instead of suspending
the device.

Fixes: 672865080a8f ("Input: cyapa - add runtime power management support")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
Changes in v2:
- Apologies for the late reply.
- Use pm_runtime_put_autosuspend() instead of
pm_runtime_put_sync_autosuspend() on the error path: the synchronous
variant was only there to mirror the normal flow, and with the 2 s
autosuspend delay the put only arms the timer, so there is nothing to
wait for.
- Link to v1: https://lore.kernel.org/all/20260916185015.2093520-1-vulab@xxxxxxxxxxx/
- Link to the June posting of the same change:
https://lore.kernel.org/all/20260609004617.175476-1-vulab@xxxxxxxxxxx/
---
drivers/input/mouse/cyapa.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
index a8e9b9ab9f84..737fc54539d9 100644
--- a/drivers/input/mouse/cyapa.c
+++ b/drivers/input/mouse/cyapa.c
@@ -900,8 +900,10 @@ static ssize_t cyapa_update_rt_suspend_scanrate(struct device *dev,
pm_runtime_get_sync(dev);

error = mutex_lock_interruptible(&cyapa->state_sync_lock);
- if (error)
+ if (error) {
+ pm_runtime_put_autosuspend(dev);
return error;
+ }

cyapa->runtime_suspend_sleep_time = min_t(u16, time, 1000);
cyapa->runtime_suspend_power_mode =
--
2.34.1