Skip to content

Commit

Permalink
net: pktgen: fix null ptr deref in skb allocation
Browse files Browse the repository at this point in the history
Fix possible null pointer dereference that may occur when calling
skb_reserve() on a null skb.

Fixes: 879c722 ("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>
  • Loading branch information
John Fastabend authored and David S. Miller committed Jan 11, 2016
1 parent 366f293 commit 3de0359
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/core/pktgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 3de0359

Please sign in to comment.