net: fix sock_clone reference mismatch with tcp memcontrol
Sockets can also be created through sock_clone. Because it copies all data in the sock structure, it also copies the memcg-related pointer, and all should be fine. However, since we now use reference counts in socket creation, we are left with some sockets that have no reference counts. It matters when we destroy them, since it leads to a mismatch. Signed-off-by: Glauber Costa <glommer@parallels.com> CC: David S. Miller <davem@davemloft.net> CC: Greg Thelen <gthelen@google.com> CC: Hiroyouki Kamezawa <kamezawa.hiroyu@jp.fujitsu.com> CC: Laurent Chavey <chavey@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
356b95424c
commit
f3f511e1ce
@@ -1362,6 +1362,8 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
|
||||
sk_set_socket(newsk, NULL);
|
||||
newsk->sk_wq = NULL;
|
||||
|
||||
sk_update_clone(sk, newsk);
|
||||
|
||||
if (newsk->sk_prot->sockets_allocated)
|
||||
sk_sockets_allocated_inc(newsk);
|
||||
|
||||
|
Reference in New Issue
Block a user