net: sk_free() should be allowed right after sk_alloc()
After commit 2b85a34e91
(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>
This commit is contained in:
Родитель
38bddf04bc
Коммит
d66ee0587c
|
@ -1025,6 +1025,7 @@ struct sock *sk_alloc(struct net *net, int family, gfp_t priority,
|
|||
sk->sk_prot = sk->sk_prot_creator = prot;
|
||||
sock_lock_init(sk);
|
||||
sock_net_set(sk, get_net(net));
|
||||
atomic_set(&sk->sk_wmem_alloc, 1);
|
||||
}
|
||||
|
||||
return sk;
|
||||
|
@ -1872,7 +1873,6 @@ void sock_init_data(struct socket *sock, struct sock *sk)
|
|||
*/
|
||||
smp_wmb();
|
||||
atomic_set(&sk->sk_refcnt, 1);
|
||||
atomic_set(&sk->sk_wmem_alloc, 1);
|
||||
atomic_set(&sk->sk_drops, 0);
|
||||
}
|
||||
EXPORT_SYMBOL(sock_init_data);
|
||||
|
|
Загрузка…
Ссылка в новой задаче