Skip to content

Commit 02c3c64

Browse files
Thomas-fourieropsiff
authored andcommitted
crypto: inside-secure - Fix dma_unmap_sg() nents value
[ Upstream commit cb7fa6b6fc71e0c801e271aa498e2f19e6df2931 ] The `dma_unmap_sg()` functions should be called with the same nents as the `dma_map_sg()`, not the value the map function returned. Fixes: c957f8b ("crypto: inside-secure - avoid unmapping DMA memory that was not mapped") Signed-off-by: Thomas Fourier <[email protected]> Reviewed-by: Antoine Tenart <[email protected]> Signed-off-by: Herbert Xu <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit a762bbe1126982ceb64e4a0e3cda51171ad92231)
1 parent 81e9da6 commit 02c3c64

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/crypto/inside-secure/safexcel_hash.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,9 @@ static int safexcel_handle_req_result(struct safexcel_crypto_priv *priv,
249249
safexcel_complete(priv, ring);
250250

251251
if (sreq->nents) {
252-
dma_unmap_sg(priv->dev, areq->src, sreq->nents, DMA_TO_DEVICE);
252+
dma_unmap_sg(priv->dev, areq->src,
253+
sg_nents_for_len(areq->src, areq->nbytes),
254+
DMA_TO_DEVICE);
253255
sreq->nents = 0;
254256
}
255257

@@ -497,7 +499,9 @@ static int safexcel_ahash_send_req(struct crypto_async_request *async, int ring,
497499
DMA_FROM_DEVICE);
498500
unmap_sg:
499501
if (req->nents) {
500-
dma_unmap_sg(priv->dev, areq->src, req->nents, DMA_TO_DEVICE);
502+
dma_unmap_sg(priv->dev, areq->src,
503+
sg_nents_for_len(areq->src, areq->nbytes),
504+
DMA_TO_DEVICE);
501505
req->nents = 0;
502506
}
503507
cdesc_rollback:

0 commit comments

Comments
 (0)