Skip to content

Commit

Permalink
gve: fix for null pointer dereference.
Browse files Browse the repository at this point in the history
Avoid passing NULL skb to __skb_put() function call if
napi_alloc_skb() returns NULL.

Fixes: 37149e9 ("gve: Implement packet continuation for RX.")
Signed-off-by: Ameer Hamza <amhamza.mgc@gmail.com>
Link: https://lore.kernel.org/r/20211205183810.8299-1-amhamza.mgc@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Ameer Hamza authored and Jakub Kicinski committed Dec 8, 2021
1 parent 6ebe4b3 commit e6f60c5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/net/ethernet/google/gve/gve_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ struct sk_buff *gve_rx_copy(struct net_device *dev, struct napi_struct *napi,
set_protocol = ctx->curr_frag_cnt == ctx->expected_frag_cnt - 1;
} else {
skb = napi_alloc_skb(napi, len);

if (unlikely(!skb))
return NULL;
set_protocol = true;
}
__skb_put(skb, len);
Expand Down

0 comments on commit e6f60c5

Please sign in to comment.