ipv4: fix data-races around inet->inet_id
[platform/kernel/linux-starfive.git] / net / ipv4 / tcp_ipv4.c
index 08921b9..f9b8a4a 100644 (file)
@@ -312,7 +312,7 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
                                             inet->inet_daddr));
        }
 
-       inet->inet_id = get_random_u16();
+       atomic_set(&inet->inet_id, get_random_u16());
 
        if (tcp_fastopen_defer_connect(sk, &err))
                return err;
@@ -1539,7 +1539,7 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,
        inet_csk(newsk)->icsk_ext_hdr_len = 0;
        if (inet_opt)
                inet_csk(newsk)->icsk_ext_hdr_len = inet_opt->opt.optlen;
-       newinet->inet_id = get_random_u16();
+       atomic_set(&newinet->inet_id, get_random_u16());
 
        /* Set ToS of the new socket based upon the value of incoming SYN.
         * ECT bits are set later in tcp_init_transfer().