[PATCH] crypto: omap-sham: fix crypto engine cleanup

Guangshuo Li posted 1 patch 1 week, 5 days ago
drivers/crypto/omap-sham.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] crypto: omap-sham: fix crypto engine cleanup
Posted by Guangshuo Li 1 week, 5 days ago
omap_sham_probe() allocates and starts a crypto engine, but the remove
path does not call the matching crypto_engine_exit(). The probe failure
path already performs this cleanup.

crypto_engine_alloc_init() creates a kthread worker for processing
requests. Without crypto_engine_exit() during driver removal, the
worker is left running after the device is removed.

Call crypto_engine_exit() after unregistering the algorithms and before
tearing down the remaining request handling resources. This stops the
engine and destroys its worker.

This issue was found by manual code inspection.

Fixes: 133c3d434d91 ("crypto: omap-sham - convert to use crypto engine")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
 drivers/crypto/omap-sham.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
index 6d2dd0b88f15..207fc7680c8f 100644
--- a/drivers/crypto/omap-sham.c
+++ b/drivers/crypto/omap-sham.c
@@ -2129,6 +2129,7 @@ static void omap_sham_remove(struct platform_device *pdev)
 	list_del(&dd->list);
 	spin_unlock_bh(&sham.lock);
 	omap_sham_unregister_algs(dd->pdata);
+	crypto_engine_exit(dd->engine);
 	cancel_work_sync(&dd->done_task);
 	pm_runtime_dont_use_autosuspend(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-- 
2.43.0
Re: [PATCH] crypto: omap-sham: fix crypto engine cleanup
Posted by Herbert Xu 1 week ago
On Sat, Sep 12, 2026 at 10:46:08PM +0800, Guangshuo Li wrote:
> omap_sham_probe() allocates and starts a crypto engine, but the remove
> path does not call the matching crypto_engine_exit(). The probe failure
> path already performs this cleanup.
> 
> crypto_engine_alloc_init() creates a kthread worker for processing
> requests. Without crypto_engine_exit() during driver removal, the
> worker is left running after the device is removed.
> 
> Call crypto_engine_exit() after unregistering the algorithms and before
> tearing down the remaining request handling resources. This stops the
> engine and destroys its worker.
> 
> This issue was found by manual code inspection.
> 
> Fixes: 133c3d434d91 ("crypto: omap-sham - convert to use crypto engine")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> ---
>  drivers/crypto/omap-sham.c | 1 +
>  1 file changed, 1 insertion(+)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt