From: John Fastabend Date: Mon, 11 Jan 2016 05:38:44 +0000 (-0800) Subject: net: pktgen: fix null ptr deref in skb allocation X-Git-Tag: v4.14-rc1~4003^2~24 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3de03596dfeee48bc803c1d1a6daf60a459929f3;p=platform%2Fkernel%2Flinux-rpi.git net: pktgen: fix null ptr deref in skb allocation 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 Signed-off-by: David S. Miller --- 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; }