public inbox for linux-crypto@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: af_alg - use sock_kmemdup in alg_setkey_by_key_serial
@ 2026-04-05 19:49 Thorsten Blum
  0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2026-04-05 19:49 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller; +Cc: Thorsten Blum, linux-crypto, linux-kernel

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

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 crypto/af_alg.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index 8e0199394984..25d2bfae31dc 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -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);
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-04-05 19:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-05 19:49 [PATCH] crypto: af_alg - use sock_kmemdup in alg_setkey_by_key_serial Thorsten Blum

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