Skip to contentSkip to conversation

crypto: talitos - fix size calculation in talitos_edesc_alloc()

PATCH Applied Dan Carpenter 3 participants 3 messages May 11, 2015 – May 13, 2015

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

PATCH 1/1 crypto: talitos - fix size calculation in talitos_edesc_alloc()

The + operation has higher precedence than ?: so we need parentheses here. Otherwise we may end up allocating a max of only one "cryptlen" instead of two.

Fixes 6f65f6ac5fb3 ('crypto: talitos - implement scatter/gather copy for SEC1')
drivers/crypto/talitos.c +2 -2
index c04074d..273942c 100644
@@ -1335,8 +1335,8 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev,
 	alloc_len = sizeof(struct talitos_edesc);
 	if (assoc_nents || src_nents || dst_nents) {
 		if (is_sec1)
-			dma_len = src_nents ? cryptlen : 0 +
-				  dst_nents ? cryptlen : 0;
+			dma_len = (src_nents ? cryptlen : 0) +
+				  (dst_nents ? cryptlen : 0);
 		else
 			dma_len = (src_nents + dst_nents + 2 + assoc_nents) *
 				  sizeof(struct talitos_ptr) + authsize;
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Dan Carpenter

The + operation has higher precedence than ?: so we need parentheses here. Otherwise we may end up allocating a max of only one "cryptlen" instead of two.

Fixes 6f65f6ac5fb3 ('crypto: talitos - implement scatter/gather copy for SEC1')
Quoted 7 lines
drivers/crypto/talitos.c +0 -0
index c04074d..273942c 100644

drivers/crypto/talitos.c static struct talitos_edesc *talitos_edesc_alloc(struct device *dev, · line 1342

Quoted 10 lines
drivers/crypto/talitos.c +2 -2
@@ -1335,8 +1335,8 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev,
  	alloc_len = sizeof(struct talitos_edesc);
  	if (assoc_nents || src_nents || dst_nents) {
  		if (is_sec1)
-			dma_len = src_nents ? cryptlen : 0 +
-				  dst_nents ? cryptlen : 0;
+			dma_len = (src_nents ? cryptlen : 0) +
+				  (dst_nents ? cryptlen : 0);
  		else
  			dma_len = (src_nents + dst_nents + 2 + assoc_nents) *
  				  sizeof(struct talitos_ptr) + authsize;

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer Applied
#2 lore raw
Quoted 10 lines · leroy christophe
Quoted 6 lines · Dan Carpenter

The + operation has higher precedence than ?: so we need parentheses here. Otherwise we may end up allocating a max of only one "cryptlen" instead of two.

Fixes 6f65f6ac5fb3 ('crypto: talitos - implement scatter/gather copy for SEC1')

Applied.

Signature · 7 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html