[PATCH] crypto: hifn_795x - Free walk pages on session setup failure
From: Haoxiang Li
Date: Wed Nov 18 2026 - 01:20:54 EST
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@xxxxxxx>
---
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