Skip to contentSkip to conversation

crypto: sl3516 - drop invalid sg_dma_len checks before DMA mapping

PATCH In review Thorsten Blum 3 participants 3 messages Jul 10 – Jul 17

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: sl3516 - drop invalid sg_dma_len checks before DMA mapping

sg_dma_len() is only valid after mapping the scatterlist with dma_map_sg(). However, sl3516_ce_need_fallback() checks it before the source and destination scatterlists are mapped. Thus, a stale DMA length that is not a multiple of 16 could incorrectly force a software fallback when CONFIG_NEED_SG_DMA_LENGTH=y.

Remove the invalid checks; the existing scatterlist length checks are sufficient.

Fixes 46c5338db7bd ("crypto: sl3516 - Add sl3516 crypto engine")
---
 drivers/crypto/gemini/sl3516-ce-cipher.c | 8 --------
 1 file changed, 8 deletions(-)
drivers/crypto/gemini/sl3516-ce-cipher.c +0 -8
index 583010b2d007..02ec4282333b 100644
@@ -56,10 +56,6 @@ static bool sl3516_ce_need_fallback(struct skcipher_request *areq)
 			ce->fallback_mod16++;
 			return true;
 		}
-		if ((sg_dma_len(sg) % 16) != 0) {
-			ce->fallback_mod16++;
-			return true;
-		}
 		if (!IS_ALIGNED(sg->offset, 16)) {
 			ce->fallback_align16++;
 			return true;
@@ -72,10 +68,6 @@ static bool sl3516_ce_need_fallback(struct skcipher_request *areq)
 			ce->fallback_mod16++;
 			return true;
 		}
-		if ((sg_dma_len(sg) % 16) != 0) {
-			ce->fallback_mod16++;
-			return true;
-		}
 		if (!IS_ALIGNED(sg->offset, 16)) {
 			ce->fallback_align16++;
 			return true;
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Thorsten Blum

sg_dma_len() is only valid after mapping the scatterlist with dma_map_sg(). However, sl3516_ce_need_fallback() checks it before the source and destination scatterlists are mapped. Thus, a stale DMA length that is not a multiple of 16 could incorrectly force a software fallback when CONFIG_NEED_SG_DMA_LENGTH=y.

Remove the invalid checks; the existing scatterlist length checks are sufficient.

Fixes 46c5338db7bd ("crypto: sl3516 - Add sl3516 crypto engine")

Looks right to me.

Yours,
Linus Walleij

maintainer
#2 lore raw
In reply to Thorsten Blum
Quoted 6 lines · Thorsten Blum

sg_dma_len() is only valid after mapping the scatterlist with dma_map_sg(). However, sl3516_ce_need_fallback() checks it before the source and destination scatterlists are mapped. Thus, a stale DMA length that is not a multiple of 16 could incorrectly force a software fallback when CONFIG_NEED_SG_DMA_LENGTH=y.

Quoted 8 lines

Remove the invalid checks; the existing scatterlist length checks are sufficient.

Fixes 46c5338db7bd ("crypto: sl3516 - Add sl3516 crypto engine")
---
 drivers/crypto/gemini/sl3516-ce-cipher.c | 8 --------
 1 file changed, 8 deletions(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt