Merge branch 'net-fix-two-issues-in-sk_clone-error-path'

Kuniyuki Iwashima says:

====================
net: Fix two issues in sk_clone() error path.

Sashiko reported issues in the sk_clone() error path.

  https://lore.kernel.org/bpf/20260709032007.9E4D61F000E9@smtp.kernel.org/

This series fixes them.
====================

Link: https://patch.msgid.link/20260709183315.965751-1-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Jakub Kicinski 2026-07-21 09:15:00 -07:00
commit fca68249b6

View File

@ -2544,6 +2544,11 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority,
cgroup_sk_clone(&newsk->sk_cgrp_data);
RCU_INIT_POINTER(newsk->sk_reuseport_cb, NULL);
if (sock_needs_netstamp(sk) && newsk->sk_flags & SK_FLAGS_TIMESTAMP)
net_enable_timestamp();
rcu_read_lock();
filter = rcu_dereference(sk->sk_filter);
if (filter != NULL)
@ -2566,8 +2571,6 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority,
goto free;
}
RCU_INIT_POINTER(newsk->sk_reuseport_cb, NULL);
if (bpf_sk_storage_clone(sk, newsk))
goto free;
@ -2595,9 +2598,6 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority,
if (newsk->sk_prot->sockets_allocated)
sk_sockets_allocated_inc(newsk);
if (sock_needs_netstamp(sk) && newsk->sk_flags & SK_FLAGS_TIMESTAMP)
net_enable_timestamp();
out:
return newsk;
free: