net: avoid NULL deref in napi_get_frags()
authorEric Dumazet <edumazet@google.com>
Thu, 19 Nov 2015 20:11:23 +0000 (12:11 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 20 Nov 2015 21:43:14 +0000 (16:43 -0500)
napi_alloc_skb() can return NULL.
We should not crash should this happen.

Fixes: 93f93a440415 ("net: move skb_mark_napi_id() into core networking stack")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/dev.c

index 41cef3e3f558b857a9093a83f6b0c73f32b8b45f..5df6cbce727c140684b84129c26ffc0606260cbb 100644 (file)
@@ -4390,8 +4390,10 @@ struct sk_buff *napi_get_frags(struct napi_struct *napi)
 
        if (!skb) {
                skb = napi_alloc_skb(napi, GRO_MAX_HEAD);
-               napi->skb = skb;
-               skb_mark_napi_id(skb, napi);
+               if (skb) {
+                       napi->skb = skb;
+                       skb_mark_napi_id(skb, napi);
+               }
        }
        return skb;
 }