[PATCH v2 4/7] crypto: qce - do not free an uninitialized dst_tbl on the error path

From: ZhaoJinming

Date: Fri Nov 13 2026 - 05:12:18 EST


qce_aead_async_req_handle() jumps to error_free when mapping or starting
a request fails. For a CCM request without associated data that is
decrypted in place, qce_aead_ccm_prepare_buf() does not allocate
rctx->dst_tbl, so the else branch of error_free releases an uninitialized
sg_table:

} else {
sg_free_table(&rctx->dst_tbl);
}

The request context comes from aead_request_alloc(), which uses
kmalloc(), so this can pass a garbage sgl pointer to sg_free_table() and
crash the kernel.

qce_aead_done() already skips this case with
!(IS_DECRYPT(rctx->flags) && !diff_dst). Apply the same check to the
error path so the uninitialized table is not freed.

Fixes: 9363efb4181c ("crypto: qce - Add support for AEAD algorithms")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: ZhaoJinming <zhaojinming@xxxxxxxxxxxxx>
---
drivers/crypto/qce/aead.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/qce/aead.c b/drivers/crypto/qce/aead.c
index 15ce778f019a..dd369328c8a6 100644
--- a/drivers/crypto/qce/aead.c
+++ b/drivers/crypto/qce/aead.c
@@ -493,7 +493,7 @@ qce_aead_async_req_handle(struct crypto_async_request *async_req)
if (diff_dst)
sg_free_table(&rctx->dst_tbl);
kfree(rctx->adata);
- } else {
+ } else if (!(IS_CCM(rctx->flags) && IS_DECRYPT(rctx->flags) && !diff_dst)) {
sg_free_table(&rctx->dst_tbl);
}
return ret;

--
2.50.1