mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-09 22:14:36 -04:00
inet: reduce inet_csk_clone_lock() indent level
Return early from inet_csk_clone_lock() if the socket allocation failed, to reduce the indentation level. Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com> Link: https://patch.msgid.link/20250212131328.1514243-2-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
a045e40645
commit
55250b83b0
@@ -1237,39 +1237,43 @@ struct sock *inet_csk_clone_lock(const struct sock *sk,
|
||||
const gfp_t priority)
|
||||
{
|
||||
struct sock *newsk = sk_clone_lock(sk, priority);
|
||||
struct inet_connection_sock *newicsk;
|
||||
|
||||
if (newsk) {
|
||||
struct inet_connection_sock *newicsk = inet_csk(newsk);
|
||||
if (!newsk)
|
||||
return NULL;
|
||||
|
||||
inet_sk_set_state(newsk, TCP_SYN_RECV);
|
||||
newicsk->icsk_bind_hash = NULL;
|
||||
newicsk->icsk_bind2_hash = NULL;
|
||||
newicsk = inet_csk(newsk);
|
||||
|
||||
inet_sk(newsk)->inet_dport = inet_rsk(req)->ir_rmt_port;
|
||||
inet_sk(newsk)->inet_num = inet_rsk(req)->ir_num;
|
||||
inet_sk(newsk)->inet_sport = htons(inet_rsk(req)->ir_num);
|
||||
inet_sk_set_state(newsk, TCP_SYN_RECV);
|
||||
newicsk->icsk_bind_hash = NULL;
|
||||
newicsk->icsk_bind2_hash = NULL;
|
||||
|
||||
/* listeners have SOCK_RCU_FREE, not the children */
|
||||
sock_reset_flag(newsk, SOCK_RCU_FREE);
|
||||
inet_sk(newsk)->inet_dport = inet_rsk(req)->ir_rmt_port;
|
||||
inet_sk(newsk)->inet_num = inet_rsk(req)->ir_num;
|
||||
inet_sk(newsk)->inet_sport = htons(inet_rsk(req)->ir_num);
|
||||
|
||||
inet_sk(newsk)->mc_list = NULL;
|
||||
/* listeners have SOCK_RCU_FREE, not the children */
|
||||
sock_reset_flag(newsk, SOCK_RCU_FREE);
|
||||
|
||||
newsk->sk_mark = inet_rsk(req)->ir_mark;
|
||||
atomic64_set(&newsk->sk_cookie,
|
||||
atomic64_read(&inet_rsk(req)->ir_cookie));
|
||||
inet_sk(newsk)->mc_list = NULL;
|
||||
|
||||
newicsk->icsk_retransmits = 0;
|
||||
newicsk->icsk_backoff = 0;
|
||||
newicsk->icsk_probes_out = 0;
|
||||
newicsk->icsk_probes_tstamp = 0;
|
||||
newsk->sk_mark = inet_rsk(req)->ir_mark;
|
||||
atomic64_set(&newsk->sk_cookie,
|
||||
atomic64_read(&inet_rsk(req)->ir_cookie));
|
||||
|
||||
/* Deinitialize accept_queue to trap illegal accesses. */
|
||||
memset(&newicsk->icsk_accept_queue, 0, sizeof(newicsk->icsk_accept_queue));
|
||||
newicsk->icsk_retransmits = 0;
|
||||
newicsk->icsk_backoff = 0;
|
||||
newicsk->icsk_probes_out = 0;
|
||||
newicsk->icsk_probes_tstamp = 0;
|
||||
|
||||
inet_clone_ulp(req, newsk, priority);
|
||||
/* Deinitialize accept_queue to trap illegal accesses. */
|
||||
memset(&newicsk->icsk_accept_queue, 0,
|
||||
sizeof(newicsk->icsk_accept_queue));
|
||||
|
||||
inet_clone_ulp(req, newsk, priority);
|
||||
|
||||
security_inet_csk_clone(newsk, req);
|
||||
|
||||
security_inet_csk_clone(newsk, req);
|
||||
}
|
||||
return newsk;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(inet_csk_clone_lock);
|
||||
|
||||
Reference in New Issue
Block a user