mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
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(). Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
committed by
Herbert Xu
parent
c697c5fcfb
commit
8879a3c110
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user