]> git.karo-electronics.de Git - linux-beck.git/blobdiff - include/net/sock.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[linux-beck.git] / include / net / sock.h
index 64a75458d22cc2fc4e972601972cf9ff9cf0a57a..aeed5c95f3caedcdb4c10668c67764d8557e9369 100644 (file)
@@ -843,6 +843,14 @@ static inline __must_check int sk_add_backlog(struct sock *sk, struct sk_buff *s
        if (sk_rcvqueues_full(sk, limit))
                return -ENOBUFS;
 
+       /*
+        * If the skb was allocated from pfmemalloc reserves, only
+        * allow SOCK_MEMALLOC sockets to use it as this socket is
+        * helping free memory
+        */
+       if (skb_pfmemalloc(skb) && !sock_flag(sk, SOCK_MEMALLOC))
+               return -ENOMEM;
+
        __sk_add_backlog(sk, skb);
        sk->sk_backlog.len += skb->truesize;
        return 0;