[PATCH] crypto: chelsio - unmap the IV with its mapped size
From: Thomas Fourier
Date: Fri Nov 27 2026 - 11:33:57 EST
chcr_aead_dma_map() maps reqctx->iv with IV + reqctx->b0_len bytes, but
when mapping the source or destination scatterlist fails its error path
unmaps only IV bytes. For CCM b0_len is not zero, so the unmap may leave
parts of the buffer mapped. This may violate safety garuaties provided
by IOMMU for example.
Unmap with IV + reqctx->b0_len, as chcr_aead_dma_unmap() does.
Signed-off-by: Thomas Fourier <fourier.thomas@xxxxxxxxx>
Fixes: 4262c98aab95 ("crypto: chelsio - Remove separate buffer used for DMA map B0 block in CCM")
---
drivers/crypto/chelsio/chcr_algo.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c
index e2f2b2a6200e..ca4bde6b7b1f 100644
--- a/drivers/crypto/chelsio/chcr_algo.c
+++ b/drivers/crypto/chelsio/chcr_algo.c
@@ -2544,7 +2544,8 @@ int chcr_aead_dma_map(struct device *dev,
return 0;
err:
- dma_unmap_single(dev, reqctx->iv_dma, IV, DMA_BIDIRECTIONAL);
+ dma_unmap_single(dev, reqctx->iv_dma, IV + reqctx->b0_len,
+ DMA_BIDIRECTIONAL);
return -ENOMEM;
}
--
2.53.0