Linux cryptographic layer development
 help / color / mirror / Atom feed
* [PATCH v2 1/2] crypto: inside_secure - Avoid dma map if size is zero
@ 2022-09-06  2:51 Peter Harliman Liem
  2022-09-06  2:51 ` [PATCH v2 2/2] crypto: inside-secure - Select CRYPTO_AES config Peter Harliman Liem
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Peter Harliman Liem @ 2022-09-06  2:51 UTC (permalink / raw)
  To: atenart, herbert; +Cc: linux-crypto, linux-lgm-soc, Peter Harliman Liem

From commit d03c54419274 ("dma-mapping: disallow .map_sg
operations from returning zero on error"), dma_map_sg()
produces warning if size is 0. This results in visible
warnings if crypto length is zero.
To avoid that, we avoid calling dma_map_sg if size is zero.

Fixes: d03c54419274 ("dma-mapping: disallow .map_sg operations from returning zero on error")
Signed-off-by: Peter Harliman Liem <pliem@maxlinear.com>
---
v2:
 Add fixes tag

 drivers/crypto/inside-secure/safexcel_cipher.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/inside-secure/safexcel_cipher.c b/drivers/crypto/inside-secure/safexcel_cipher.c
index d68ef16650d4..3775497775e0 100644
--- a/drivers/crypto/inside-secure/safexcel_cipher.c
+++ b/drivers/crypto/inside-secure/safexcel_cipher.c
@@ -737,14 +737,17 @@ static int safexcel_send_req(struct crypto_async_request *base, int ring,
 				max(totlen_src, totlen_dst));
 			return -EINVAL;
 		}
-		dma_map_sg(priv->dev, src, sreq->nr_src, DMA_BIDIRECTIONAL);
+		if (sreq->nr_src > 0)
+			dma_map_sg(priv->dev, src, sreq->nr_src, DMA_BIDIRECTIONAL);
 	} else {
 		if (unlikely(totlen_src && (sreq->nr_src <= 0))) {
 			dev_err(priv->dev, "Source buffer not large enough (need %d bytes)!",
 				totlen_src);
 			return -EINVAL;
 		}
-		dma_map_sg(priv->dev, src, sreq->nr_src, DMA_TO_DEVICE);
+
+		if (sreq->nr_src > 0)
+			dma_map_sg(priv->dev, src, sreq->nr_src, DMA_TO_DEVICE);
 
 		if (unlikely(totlen_dst && (sreq->nr_dst <= 0))) {
 			dev_err(priv->dev, "Dest buffer not large enough (need %d bytes)!",
@@ -753,7 +756,9 @@ static int safexcel_send_req(struct crypto_async_request *base, int ring,
 				     DMA_TO_DEVICE);
 			return -EINVAL;
 		}
-		dma_map_sg(priv->dev, dst, sreq->nr_dst, DMA_FROM_DEVICE);
+
+		if (sreq->nr_dst > 0)
+			dma_map_sg(priv->dev, dst, sreq->nr_dst, DMA_FROM_DEVICE);
 	}
 
 	memcpy(ctx->base.ctxr->data, ctx->key, ctx->key_len);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-09-23  2:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-06  2:51 [PATCH v2 1/2] crypto: inside_secure - Avoid dma map if size is zero Peter Harliman Liem
2022-09-06  2:51 ` [PATCH v2 2/2] crypto: inside-secure - Select CRYPTO_AES config Peter Harliman Liem
2022-09-06 14:05   ` Antoine Tenart
2022-09-07  6:46     ` Peter Harliman Liem
2022-09-07  8:48       ` Antoine Tenart
2022-09-23  2:39         ` Peter Harliman Liem
2022-09-06 14:00 ` [PATCH v2 1/2] crypto: inside_secure - Avoid dma map if size is zero Antoine Tenart
2022-09-07  6:43   ` Peter Harliman Liem
2022-09-07  6:52 ` Herbert Xu
2022-09-23  2:35   ` Peter Harliman Liem

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox