Skip to content

Commit 8879a3c

Browse files
tobluxherbertx
authored andcommitted
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 <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent c697c5f commit 8879a3c

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

crypto/af_alg.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,15 +324,13 @@ static int alg_setkey_by_key_serial(struct alg_sock *ask, sockptr_t optval,
324324
return PTR_ERR(ret);
325325
}
326326

327-
key_data = sock_kmalloc(&ask->sk, key_datalen, GFP_KERNEL);
327+
key_data = sock_kmemdup(&ask->sk, ret, key_datalen, GFP_KERNEL);
328328
if (!key_data) {
329329
up_read(&key->sem);
330330
key_put(key);
331331
return -ENOMEM;
332332
}
333333

334-
memcpy(key_data, ret, key_datalen);
335-
336334
up_read(&key->sem);
337335
key_put(key);
338336

0 commit comments

Comments
 (0)