From f3f511e1ce6f1a6f0a5bb8320e9f802e76f6b999 Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Thu, 5 Jan 2012 20:16:39 +0000 Subject: 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 CC: David S. Miller CC: Greg Thelen CC: Hiroyouki Kamezawa CC: Laurent Chavey Signed-off-by: David S. Miller --- include/net/sock.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include/net') diff --git a/include/net/sock.h b/include/net/sock.h index bb972d254dff..0ed65e3a0bea 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1103,6 +1103,12 @@ sk_sockets_allocated_read_positive(struct sock *sk) return percpu_counter_sum_positive(prot->sockets_allocated); } +static inline void sk_update_clone(const struct sock *sk, struct sock *newsk) +{ + if (mem_cgroup_sockets_enabled && sk->sk_cgrp) + sock_update_memcg(newsk); +} + static inline int proto_sockets_allocated_sum_positive(struct proto *prot) { -- cgit v1.2.1