Merge branch 'for-linus2' of git://git.kernel.org/pub/scm/linux/kernel/git/vegard...
[firefly-linux-kernel-4.4.55.git] / include / net / sock.h
index d933da00d5050511acea852048eb7b84f2c0f027..95bd3fd75f942d42351cd42450420334fef6f2a0 100644 (file)
@@ -1219,9 +1219,13 @@ static inline int skb_copy_to_page(struct sock *sk, char __user *from,
 
 static inline void skb_set_owner_w(struct sk_buff *skb, struct sock *sk)
 {
-       sock_hold(sk);
        skb->sk = sk;
        skb->destructor = sock_wfree;
+       /*
+        * We used to take a refcount on sk, but following operation
+        * is enough to guarantee sk_free() wont free this sock until
+        * all in-flight packets are completed
+        */
        atomic_add(skb->truesize, &sk->sk_wmem_alloc);
 }