All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: hifn_795x - Free walk pages on session setup failure
@ 2026-11-18  6:19 Haoxiang Li
  2026-11-18  6:38 ` sashiko-bot
  2026-11-18  6:55 ` Eric Biggers
  0 siblings, 2 replies; 3+ messages in thread
From: Haoxiang Li @ 2026-11-18  6:19 UTC (permalink / raw)
  To: herbert, davem, johnpol, linux-crypto, linux-kernel; +Cc: Haoxiang Li

hifn_setup_session() allocates temporary pages for misaligned destination
buffers. If the scatterlist walk fails or the hardware queue has
insufficient capacity, these pages are not released. Retrying a queued
request reinitializes the walk cache, losing the previous page pointers.
Add a separate cleanup path to release the pages for misaligned requests.

Fixes: f7d0561ea1da ("[CRYPTO] hifn_795x: HIFN 795x driver")
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
---
 drivers/crypto/hifn_795x.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
index 46bcef044606..73a661085d97 100644
--- a/drivers/crypto/hifn_795x.c
+++ b/drivers/crypto/hifn_795x.c
@@ -1539,7 +1539,7 @@ static int hifn_setup_session(struct skcipher_request *req)
 	sg_num = hifn_cipher_walk(req, &rctx->walk);
 	if (sg_num < 0) {
 		err = sg_num;
-		goto err_out_exit;
+		goto err_out_free;
 	}
 
 	spin_lock_irqsave(&dev->lock, flags);
@@ -1561,6 +1561,9 @@ static int hifn_setup_session(struct skcipher_request *req)
 
 err_out:
 	spin_unlock_irqrestore(&dev->lock, flags);
+err_out_free:
+	if (rctx->walk.flags & ASYNC_FLAGS_MISALIGNED)
+		hifn_cipher_walk_exit(&rctx->walk);
 err_out_exit:
 	if (err) {
 		dev_info(&dev->pdev->dev, "iv: %p [%d], key: %p [%d], mode: %u, op: %u, "
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-18  6:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18  6:19 [PATCH] crypto: hifn_795x - Free walk pages on session setup failure Haoxiang Li
2026-11-18  6:38 ` sashiko-bot
2026-11-18  6:55 ` Eric Biggers

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.