* [PATCH] crypto: sl3516: fix autosuspend cleanup during teardown
@ 2026-08-08 9:26 Guangshuo Li
2026-08-09 22:15 ` Linus Walleij
0 siblings, 1 reply; 2+ messages in thread
From: Guangshuo Li @ 2026-08-08 9:26 UTC (permalink / raw)
To: Corentin Labbe, Hans Ulli Kroll, Linus Walleij, Herbert Xu,
David S. Miller, linux-crypto, linux-arm-kernel, linux-kernel
Cc: Guangshuo Li, stable
sl3516_ce_pm_init() calls pm_runtime_use_autosuspend(), but the
autosuspend setting is not undone if pm_runtime_set_suspended() fails
or when runtime PM is later torn down by sl3516_ce_pm_exit().
If the autosuspend delay is set to a negative value while autosuspend
is enabled, the runtime PM core increments usage_count to prevent
runtime suspend. Without calling pm_runtime_dont_use_autosuspend()
during cleanup, this reference is not dropped and usage_count remains
unbalanced.
Undo the autosuspend setting when pm_runtime_set_suspended() fails and
in sl3516_ce_pm_exit() before disabling runtime PM.
This issue was found by manual code inspection.
Fixes: 46c5338db7bd ("crypto: sl3516 - Add sl3516 crypto engine")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
drivers/crypto/gemini/sl3516-ce-core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/crypto/gemini/sl3516-ce-core.c b/drivers/crypto/gemini/sl3516-ce-core.c
index f7e0e3fea15c..f09a7f3445e4 100644
--- a/drivers/crypto/gemini/sl3516-ce-core.c
+++ b/drivers/crypto/gemini/sl3516-ce-core.c
@@ -381,14 +381,17 @@ static int sl3516_ce_pm_init(struct sl3516_ce_dev *ce)
pm_runtime_set_autosuspend_delay(ce->dev, 2000);
err = pm_runtime_set_suspended(ce->dev);
- if (err)
+ if (err) {
+ pm_runtime_dont_use_autosuspend(ce->dev);
return err;
+ }
pm_runtime_enable(ce->dev);
return err;
}
static void sl3516_ce_pm_exit(struct sl3516_ce_dev *ce)
{
+ pm_runtime_dont_use_autosuspend(ce->dev);
pm_runtime_disable(ce->dev);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] crypto: sl3516: fix autosuspend cleanup during teardown
2026-08-08 9:26 [PATCH] crypto: sl3516: fix autosuspend cleanup during teardown Guangshuo Li
@ 2026-08-09 22:15 ` Linus Walleij
0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2026-08-09 22:15 UTC (permalink / raw)
To: Guangshuo Li
Cc: Corentin Labbe, Hans Ulli Kroll, Herbert Xu, David S. Miller,
linux-crypto, linux-arm-kernel, linux-kernel, stable
On Sat, Aug 8, 2026 at 11:26 AM Guangshuo Li <lgs201920130244@gmail.com> wrote:
> sl3516_ce_pm_init() calls pm_runtime_use_autosuspend(), but the
> autosuspend setting is not undone if pm_runtime_set_suspended() fails
> or when runtime PM is later torn down by sl3516_ce_pm_exit().
>
> If the autosuspend delay is set to a negative value while autosuspend
> is enabled, the runtime PM core increments usage_count to prevent
> runtime suspend. Without calling pm_runtime_dont_use_autosuspend()
> during cleanup, this reference is not dropped and usage_count remains
> unbalanced.
>
> Undo the autosuspend setting when pm_runtime_set_suspended() fails and
> in sl3516_ce_pm_exit() before disabling runtime PM.
>
> This issue was found by manual code inspection.
>
> Fixes: 46c5338db7bd ("crypto: sl3516 - Add sl3516 crypto engine")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
Looks right to me!
Reviewed-by: Linus Walleij <linusw@kernel.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-09 22:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-08 9:26 [PATCH] crypto: sl3516: fix autosuspend cleanup during teardown Guangshuo Li
2026-08-09 22:15 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox