Skip to content

Commit

Permalink
net: lantiq_xrx200: confirm skb is allocated before using
Browse files Browse the repository at this point in the history
xrx200_hw_receive() assumes build_skb() always works and goes straight
to skb_reserve(). However, build_skb() can fail under memory pressure.

Add a check in case build_skb() failed to allocate and return NULL.

Fixes: e015593 ("net: lantiq_xrx200: convert to build_skb")
Reported-by: Eric Dumazet <[email protected]>
Signed-off-by: Aleksander Jan Bajkowski <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
abajk authored and kuba-moo committed Aug 25, 2022
1 parent a3a57bf commit c8b0437
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/net/ethernet/lantiq_xrx200.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ static int xrx200_hw_receive(struct xrx200_chan *ch)
}

skb = build_skb(buf, priv->rx_skb_size);
if (!skb) {
skb_free_frag(buf);
net_dev->stats.rx_dropped++;
return -ENOMEM;
}

skb_reserve(skb, NET_SKB_PAD);
skb_put(skb, len);

Expand Down

0 comments on commit c8b0437

Please sign in to comment.