diff options
author | Li RongQing <lirongqing@baidu.com> | 2019-02-22 04:08:22 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-02-24 15:37:23 -0500 |
commit | c2f26e8f8788dbd911692d983a3ece83d7d66fbb (patch) | |
tree | 881457ec92c33eb7d5f3d61d94a5b84975d98bff | |
parent | b6a4119d9d01633d78409fed457fbe840c757f79 (diff) |
net: Use RCU_INIT_POINTER() to set sk_wq
This pointer is RCU protected, so proper primitives should be used.
Signed-off-by: Zhang Yu <zhangyu31@baidu.com>
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/core/sock.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index f4b8b78535f8..f5d82f3fa474 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -1865,7 +1865,7 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority) | |||
1865 | */ | 1865 | */ |
1866 | sk_refcnt_debug_inc(newsk); | 1866 | sk_refcnt_debug_inc(newsk); |
1867 | sk_set_socket(newsk, NULL); | 1867 | sk_set_socket(newsk, NULL); |
1868 | newsk->sk_wq = NULL; | 1868 | RCU_INIT_POINTER(newsk->sk_wq, NULL); |
1869 | 1869 | ||
1870 | if (newsk->sk_prot->sockets_allocated) | 1870 | if (newsk->sk_prot->sockets_allocated) |
1871 | sk_sockets_allocated_inc(newsk); | 1871 | sk_sockets_allocated_inc(newsk); |
@@ -2828,11 +2828,11 @@ void sock_init_data(struct socket *sock, struct sock *sk) | |||
2828 | 2828 | ||
2829 | if (sock) { | 2829 | if (sock) { |
2830 | sk->sk_type = sock->type; | 2830 | sk->sk_type = sock->type; |
2831 | sk->sk_wq = sock->wq; | 2831 | RCU_INIT_POINTER(sk->sk_wq, sock->wq); |
2832 | sock->sk = sk; | 2832 | sock->sk = sk; |
2833 | sk->sk_uid = SOCK_INODE(sock)->i_uid; | 2833 | sk->sk_uid = SOCK_INODE(sock)->i_uid; |
2834 | } else { | 2834 | } else { |
2835 | sk->sk_wq = NULL; | 2835 | RCU_INIT_POINTER(sk->sk_wq, NULL); |
2836 | sk->sk_uid = make_kuid(sock_net(sk)->user_ns, 0); | 2836 | sk->sk_uid = make_kuid(sock_net(sk)->user_ns, 0); |
2837 | } | 2837 | } |
2838 | 2838 | ||