summaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorJohn Fastabend <john.fastabend@gmail.com>2016-01-11 06:38:44 +0100
committerDavid S. Miller <davem@davemloft.net>2016-01-11 23:39:44 +0100
commit3de03596dfeee48bc803c1d1a6daf60a459929f3 (patch)
treece22e80c90b647f7750d754668078b16b3ecd6e0 /net/core
parentMerge branch 'renesas-eth-fixes' (diff)
downloadlinux-3de03596dfeee48bc803c1d1a6daf60a459929f3.tar.xz
linux-3de03596dfeee48bc803c1d1a6daf60a459929f3.zip
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 <john.r.fastabend@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/pktgen.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index de8d5cc5eb24..4da4d51a2ccf 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;
}