* [PATCH] Input: cyapa - fix runtime PM leak in cyapa_update_rt_suspend_scanrate()
@ 2026-09-16 18:50 Wentao Liang
2026-09-17 15:15 ` Dmitry Torokhov
0 siblings, 1 reply; 4+ messages in thread
From: Wentao Liang @ 2026-09-16 18:50 UTC (permalink / raw)
To: dmitry.torokhov; +Cc: dudl, linux-input, linux-kernel, Wentao Liang, stable
pm_runtime_get_sync() unconditionally increments the runtime PM usage
counter. If mutex_lock_interruptible() is interrupted, the function
returns without dropping that reference. Add the missing
pm_runtime_put_sync_autosuspend() call on the error path.
Fixes: 672865080a8f ("Input: cyapa - add runtime power management support")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
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 6e0d956617a1..5edf4fdbb373 100644
--- a/drivers/input/mouse/cyapa.c
+++ b/drivers/input/mouse/cyapa.c
@@ -901,8 +901,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_sync_autosuspend(dev);
return error;
+ }
cyapa->runtime_suspend_sleep_time = min_t(u16, time, 1000);
cyapa->runtime_suspend_power_mode =
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] Input: cyapa - fix runtime PM leak in cyapa_update_rt_suspend_scanrate() 2026-09-16 18:50 [PATCH] Input: cyapa - fix runtime PM leak in cyapa_update_rt_suspend_scanrate() Wentao Liang @ 2026-09-17 15:15 ` Dmitry Torokhov 2026-11-08 6:45 ` [PATCH v2] " Wentao Liang 0 siblings, 1 reply; 4+ messages in thread From: Dmitry Torokhov @ 2026-09-17 15:15 UTC (permalink / raw) To: Wentao Liang; +Cc: dudl, linux-input, linux-kernel, stable Hi Wentao, On Wed, Sep 16, 2026 at 06:50:15PM +0000, Wentao Liang wrote: > pm_runtime_get_sync() unconditionally increments the runtime PM usage > counter. If mutex_lock_interruptible() is interrupted, the function > returns without dropping that reference. Add the missing > pm_runtime_put_sync_autosuspend() call on the error path. > > Fixes: 672865080a8f ("Input: cyapa - add runtime power management support") > Cc: stable@vger.kernel.org > Signed-off-by: Wentao Liang <vulab@iscas.ac.cn> > --- > 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 6e0d956617a1..5edf4fdbb373 100644 > --- a/drivers/input/mouse/cyapa.c > +++ b/drivers/input/mouse/cyapa.c > @@ -901,8 +901,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_sync_autosuspend(dev); Why does it have to be "sync" variant? Thanks. -- Dmitry ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] Input: cyapa - fix runtime PM leak in cyapa_update_rt_suspend_scanrate() 2026-09-17 15:15 ` Dmitry Torokhov @ 2026-11-08 6:45 ` Wentao Liang 2026-11-09 7:24 ` Dmitry Torokhov 0 siblings, 1 reply; 4+ messages in thread From: Wentao Liang @ 2026-11-08 6:45 UTC (permalink / raw) To: Dmitry Torokhov; +Cc: dudl, linux-input, linux-kernel, stable Hi Dmitry, Sorry for the very late reply. It does not have to be the "sync" variant. I used pm_runtime_put_sync_autosuspend() only to mirror the normal flow of the same function and the other runtime PM call sites in cyapa.c, but there is nothing on this path that needs a synchronous transition: no device state has been changed yet, both put variants mark the device busy first, and cyapa_start_runtime() sets a 2 s autosuspend delay, so either of them would only arm the autosuspend timer before the store returns. v2 uses pm_runtime_put_autosuspend(), the counterpart of pm_runtime_get_sync() for devices that use autosuspend. For the record on how the patch was produced: the candidate came from static analysis tooling, and DeepSeek and GPT-6.1 Sol were used to audit it and to help write the change. I reviewed the result and I am responsible for it. v2 is build-tested only: it compiles cleanly on x86-64 with CONFIG_MOUSE_CYAPA=y, including W=1, and passes checkpatch. I have no Cypress trackpad to test it on. Thanks, Wentao From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Wentao Liang <vulab@iscas.ac.cn> Date: Sun, 8 Nov 2026 06:45:47 +0000 Subject: [PATCH v2] Input: cyapa - fix runtime PM leak in cyapa_update_rt_suspend_scanrate() 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@vger.kernel.org Signed-off-by: Wentao Liang <vulab@iscas.ac.cn> --- 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@iscas.ac.cn/ - Link to the June posting of the same change: https://lore.kernel.org/all/20260609004617.175476-1-vulab@iscas.ac.cn/ --- 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 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] Input: cyapa - fix runtime PM leak in cyapa_update_rt_suspend_scanrate() 2026-11-08 6:45 ` [PATCH v2] " Wentao Liang @ 2026-11-09 7:24 ` Dmitry Torokhov 0 siblings, 0 replies; 4+ messages in thread From: Dmitry Torokhov @ 2026-11-09 7:24 UTC (permalink / raw) To: Wentao Liang; +Cc: dudl, linux-input, linux-kernel, stable On Sun, Nov 08, 2026 at 06:45:47AM +0000, Wentao Liang wrote: > Hi Dmitry, > > Sorry for the very late reply. > > It does not have to be the "sync" variant. I used > pm_runtime_put_sync_autosuspend() only to mirror the normal flow of the > same function and the other runtime PM call sites in cyapa.c, but there > is nothing on this path that needs a synchronous transition: no device > state has been changed yet, both put variants mark the device busy > first, and cyapa_start_runtime() sets a 2 s autosuspend delay, so either > of them would only arm the autosuspend timer before the store returns. > v2 uses pm_runtime_put_autosuspend(), the counterpart of > pm_runtime_get_sync() for devices that use autosuspend. > > For the record on how the patch was produced: the candidate came from > static analysis tooling, and DeepSeek and GPT-6.1 Sol were used to audit > it and to help write the change. I reviewed the result and I am > responsible for it. v2 is build-tested only: it compiles cleanly on > x86-64 with CONFIG_MOUSE_CYAPA=y, including W=1, and passes checkpatch. > I have no Cypress trackpad to test it on. > > Thanks, > Wentao > > From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 > From: Wentao Liang <vulab@iscas.ac.cn> > Date: Sun, 8 Nov 2026 06:45:47 +0000 > Subject: [PATCH v2] Input: cyapa - fix runtime PM leak in cyapa_update_rt_suspend_scanrate() > > 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@vger.kernel.org > Signed-off-by: Wentao Liang <vulab@iscas.ac.cn> Applied, thank you. -- Dmitry ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-09 7:24 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-09-16 18:50 [PATCH] Input: cyapa - fix runtime PM leak in cyapa_update_rt_suspend_scanrate() Wentao Liang 2026-09-17 15:15 ` Dmitry Torokhov 2026-11-08 6:45 ` [PATCH v2] " Wentao Liang 2026-11-09 7:24 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox