Thread (9 messages) 9 messages, 3 authors, 2025-02-27
STALE505d

[PATCH net-next 4/4] net/tcp_ao: use sock_kmemdup for tcp_ao_key

From: Geliang Tang <geliang@kernel.org>
Date: 2025-02-27 08:24:13
Also in: linux-sctp, mptcp
Subsystem: networking [general], networking [tcp], the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Neal Cardwell, Linus Torvalds

From: Geliang Tang <redacted>

Instead of using sock_kmalloc() to allocate a tcp_ao_key "new_key" and
then immediately duplicate the input "key" to it in tcp_ao_copy_key(),
the newly added sock_kmemdup() helper can be used to simplify the code.

Signed-off-by: Geliang Tang <redacted>
---
 net/ipv4/tcp_ao.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/net/ipv4/tcp_ao.c b/net/ipv4/tcp_ao.c
index bbb8d5f0eae7..d21412d469cc 100644
--- a/net/ipv4/tcp_ao.c
+++ b/net/ipv4/tcp_ao.c
@@ -246,12 +246,11 @@ static struct tcp_ao_key *tcp_ao_copy_key(struct sock *sk,
 {
 	struct tcp_ao_key *new_key;
 
-	new_key = sock_kmalloc(sk, tcp_ao_sizeof_key(key),
+	new_key = sock_kmemdup(sk, key, tcp_ao_sizeof_key(key),
 			       GFP_ATOMIC);
 	if (!new_key)
 		return NULL;
 
-	*new_key = *key;
 	INIT_HLIST_NODE(&new_key->node);
 	tcp_sigpool_get(new_key->tcp_sigpool_id);
 	atomic64_set(&new_key->pkt_good, 0);
-- 
2.43.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help