]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
net: pktgen: fix null ptr deref in skb allocation
authorJohn Fastabend <john.fastabend@gmail.com>
Mon, 11 Jan 2016 05:38:44 +0000 (21:38 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 31 Jan 2016 19:29:00 +0000 (11:29 -0800)
[ Upstream commit 3de03596dfeee48bc803c1d1a6daf60a459929f3 ]

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/core/pktgen.c

index de8d5cc5eb240555e2c8b30da7858b3ff9eadffb..4da4d51a2ccfd6e8b8833c35cc0604991536ed68 100644 (file)
@@ -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;
 }