Skip to content

Commit 3de0359

Browse files
jrfastabdavem330
authored andcommitted
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: 879c722 ("net: pktgen: Observe needed_headroom of the device") Signed-off-by: John Fastabend <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 366f293 commit 3de0359

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/core/pktgen.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2787,7 +2787,9 @@ static struct sk_buff *pktgen_alloc_skb(struct net_device *dev,
27872787
} else {
27882788
skb = __netdev_alloc_skb(dev, size, GFP_NOWAIT);
27892789
}
2790-
skb_reserve(skb, LL_RESERVED_SPACE(dev));
2790+
2791+
if (likely(skb))
2792+
skb_reserve(skb, LL_RESERVED_SPACE(dev));
27912793

27922794
return skb;
27932795
}

0 commit comments

Comments
 (0)