[PATCH 09/10] crypto: qce - Terminate RX DMA channel if TX preparation fails

From: Lee Jones

Date: Mon Nov 23 2026 - 10:12:17 EST


qce_dma_prep_sgs() prepares and submits the rxchan DMA descriptor via
qce_dma_prep_sg() before preparing the txchan descriptor. If the
subsequent txchan preparation fails, qce_dma_prep_sgs() returns an
error while leaving the submitted rxchan descriptor queued in the DMA
engine, and callers jump straight to unmapping their scatterlists
without calling qce_dma_terminate_all().

On the next cryptographic request, qce_dma_issue_pending() flushes the
stale rxchan descriptor against already-unmapped memory.

Terminate rxchan via dmaengine_terminate_async() when preparing txchan
fails in qce_dma_prep_sgs().

Fixes: ec8f5d8f6f76 ("crypto: qce - Qualcomm crypto engine driver")
Closes: https://sashiko.dev/#/bug/linux-0b5dbd9f-7869-4856-a8e5-47c2c6e342f1
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/crypto/qce/dma.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/qce/dma.c b/drivers/crypto/qce/dma.c
index 68cafd4741ad..726e7fd3421e 100644
--- a/drivers/crypto/qce/dma.c
+++ b/drivers/crypto/qce/dma.c
@@ -116,8 +116,12 @@ int qce_dma_prep_sgs(struct qce_dma_data *dma, struct scatterlist *rx_sg,
if (ret)
return ret;

- return qce_dma_prep_sg(txchan, tx_sg, tx_nents, flags, DMA_DEV_TO_MEM,
- cb, cb_param);
+ ret = qce_dma_prep_sg(txchan, tx_sg, tx_nents, flags, DMA_DEV_TO_MEM,
+ cb, cb_param);
+ if (ret)
+ dmaengine_terminate_async(rxchan);
+
+ return ret;
}

void qce_dma_issue_pending(struct qce_dma_data *dma)
--
2.56.1.750.gf70dc682cf-goog