[PATCH v4 10/15] crypto: ti - Terminate DMA on all error paths in AES to clear descriptors
From: T Pratham
Date: Thu Sep 10 2026 - 14:04:04 EST
dmaengine_prep_slave_sg() allocates a DMA descriptor which is freed on
either successful dmaengine_submit() or on dmaengine_terminate_sync().
The error paths after descriptor allocation was not clearing them,
leaving the descriptors orphaned and leaking memory in case of failure.
Add terminate calls in dthe_aes_run() to appropriately clean the DMA
descriptors.
Fixes: 52f641bc63a46 ("crypto: ti - Add driver for DTHE V2 AES Engine (ECB, CBC)")
Signed-off-by: T Pratham <t-pratham@xxxxxx>
---
drivers/crypto/ti/dthev2-aes.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/crypto/ti/dthev2-aes.c b/drivers/crypto/ti/dthev2-aes.c
index 65a53fcf80467..10073bbeca113 100644
--- a/drivers/crypto/ti/dthev2-aes.c
+++ b/drivers/crypto/ti/dthev2-aes.c
@@ -449,6 +449,8 @@ static int dthe_aes_run(struct crypto_engine *engine, void *areq)
if (!desc_out) {
dev_err(dev_data->dev, "OUT prep_slave_sg() failed\n");
ret = -EINVAL;
+ /* terminate to free the orphaned desc_in descriptor */
+ dmaengine_terminate_sync(dev_data->dma_aes_rx);
goto aes_prep_err;
}
--
2.34.1