diff options
author | Jarek Poplawski <jarkao2@gmail.com> | 2009-08-30 19:15:36 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-09-01 20:49:00 -0400 |
commit | d66ee0587c3927aea5178a822976c7c853d815fe (patch) | |
tree | 3367ebb2757501223ae658b23a96f352aa6ebba8 /net | |
parent | 38bddf04bcfe661fbdab94888c3b72c32f6873b3 (diff) |
net: sk_free() should be allowed right after sk_alloc()
After commit 2b85a34e911bf483c27cfdd124aeb1605145dc80
(net: No more expensive sock_hold()/sock_put() on each tx)
sk_free() frees socks conditionally and depends
on sk_wmem_alloc being set e.g. in sock_init_data(). But in some
cases sk_free() is called earlier, usually after other alloc errors.
Fix is to move sk_wmem_alloc initialization from sock_init_data()
to sk_alloc() itself.
Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/sock.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index bbb25be7ddfe..76334228ed1c 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -1025,6 +1025,7 @@ struct sock *sk_alloc(struct net *net, int family, gfp_t priority, | |||
1025 | sk->sk_prot = sk->sk_prot_creator = prot; | 1025 | sk->sk_prot = sk->sk_prot_creator = prot; |
1026 | sock_lock_init(sk); | 1026 | sock_lock_init(sk); |
1027 | sock_net_set(sk, get_net(net)); | 1027 | sock_net_set(sk, get_net(net)); |
1028 | atomic_set(&sk->sk_wmem_alloc, 1); | ||
1028 | } | 1029 | } |
1029 | 1030 | ||
1030 | return sk; | 1031 | return sk; |
@@ -1872,7 +1873,6 @@ void sock_init_data(struct socket *sock, struct sock *sk) | |||
1872 | */ | 1873 | */ |
1873 | smp_wmb(); | 1874 | smp_wmb(); |
1874 | atomic_set(&sk->sk_refcnt, 1); | 1875 | atomic_set(&sk->sk_refcnt, 1); |
1875 | atomic_set(&sk->sk_wmem_alloc, 1); | ||
1876 | atomic_set(&sk->sk_drops, 0); | 1876 | atomic_set(&sk->sk_drops, 0); |
1877 | } | 1877 | } |
1878 | EXPORT_SYMBOL(sock_init_data); | 1878 | EXPORT_SYMBOL(sock_init_data); |