diff mbox

[net-next] net: avoid NULL deref in napi_get_frags()

Message ID 1447963883.22599.243.camel@edumazet-glaptop2.roam.corp.google.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Eric Dumazet Nov. 19, 2015, 8:11 p.m. UTC
From: Eric Dumazet <edumazet@google.com>

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>
---
 net/core/dev.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

David Miller Nov. 20, 2015, 9:43 p.m. UTC | #1
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 19 Nov 2015 12:11:23 -0800

> From: Eric Dumazet <edumazet@google.com>
> 
> 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>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/core/dev.c b/net/core/dev.c
index 41cef3e3f558b857a9093a83f6b0c73f32b8b45f..5df6cbce727c140684b84129c26ffc0606260cbb 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -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;
 }