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: c957f8b3e2 ("crypto: inside-secure - avoid unmapping DMA memory that was not mapped")
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
Reviewed-by: Antoine Tenart <atenart@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
1a6a558c86
commit
f3f855d557
@@ -247,7 +247,9 @@ static int safexcel_handle_req_result(struct safexcel_crypto_priv *priv,
|
||||
safexcel_complete(priv, ring);
|
||||
|
||||
if (sreq->nents) {
|
||||
dma_unmap_sg(priv->dev, areq->src, sreq->nents, DMA_TO_DEVICE);
|
||||
dma_unmap_sg(priv->dev, areq->src,
|
||||
sg_nents_for_len(areq->src, areq->nbytes),
|
||||
DMA_TO_DEVICE);
|
||||
sreq->nents = 0;
|
||||
}
|
||||
|
||||
@@ -495,7 +497,9 @@ unmap_result:
|
||||
DMA_FROM_DEVICE);
|
||||
unmap_sg:
|
||||
if (req->nents) {
|
||||
dma_unmap_sg(priv->dev, areq->src, req->nents, DMA_TO_DEVICE);
|
||||
dma_unmap_sg(priv->dev, areq->src,
|
||||
sg_nents_for_len(areq->src, areq->nbytes),
|
||||
DMA_TO_DEVICE);
|
||||
req->nents = 0;
|
||||
}
|
||||
cdesc_rollback:
|
||||
|
||||
Reference in New Issue
Block a user