Skip to contentSkip to conversation

crypto: af_alg - use sock_kmemdup in alg_setkey_by_key_serial

PATCH In review Thorsten Blum 2 participants 2 messages Apr 5 – Apr 12 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: af_alg - use sock_kmemdup in alg_setkey_by_key_serial

Replace sock_kmalloc() followed by memcpy() with sock_kmemdup() to simplify alg_setkey_by_key_serial().

---
 crypto/af_alg.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
crypto/af_alg.c +1 -3
index 8e0199394984..25d2bfae31dc 100644
@@ -324,15 +324,13 @@ static int alg_setkey_by_key_serial(struct alg_sock *ask, sockptr_t optval,
 		return PTR_ERR(ret);
 	}
 
-	key_data = sock_kmalloc(&ask->sk, key_datalen, GFP_KERNEL);
+	key_data = sock_kmemdup(&ask->sk, ret, key_datalen, GFP_KERNEL);
 	if (!key_data) {
 		up_read(&key->sem);
 		key_put(key);
 		return -ENOMEM;
 	}
 
-	memcpy(key_data, ret, key_datalen);
-
 	up_read(&key->sem);
 	key_put(key);
 
maintainer
#1 lore raw
Quoted 7 lines · Thorsten Blum

Replace sock_kmalloc() followed by memcpy() with sock_kmemdup() to simplify alg_setkey_by_key_serial().

---
 crypto/af_alg.c | 4 +---
 1 file changed, 1 insertion(+), 3 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