netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: pktgen: fix null ptr deref in skb allocation
@ 2016-01-11  5:38 John Fastabend
  2016-01-11 22:40 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: John Fastabend @ 2016-01-11  5:38 UTC (permalink / raw)
  To: netdev; +Cc: bogdan.hamciuc, davem

Fix possible null pointer dereference that may occur when calling
skb_reserve() on a null skb.

Fixes: 879c7220e82 ("net: pktgen: Observe needed_headroom of the device")
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
 net/core/pktgen.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index de8d5cc..4da4d51 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2787,7 +2787,9 @@ static struct sk_buff *pktgen_alloc_skb(struct net_device *dev,
 	} else {
 		 skb = __netdev_alloc_skb(dev, size, GFP_NOWAIT);
 	}
-	skb_reserve(skb, LL_RESERVED_SPACE(dev));
+
+	if (likely(skb))
+		skb_reserve(skb, LL_RESERVED_SPACE(dev));
 
 	return skb;
 }

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-01-12 17:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-11  5:38 [PATCH] net: pktgen: fix null ptr deref in skb allocation John Fastabend
2016-01-11 22:40 ` David Miller
2016-01-12 17:32   ` John Fastabend

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).