Skip to content

Commit

Permalink
net: don't check skb_count twice
Browse files Browse the repository at this point in the history
NAPI cache skb_count is being checked twice without condition. Change to
checking the second time only if the first check is run.

Signed-off-by: Sieng Piaw Liew <liew.s.piaw@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Sieng Piaw Liew authored and David S. Miller committed Jun 15, 2022
1 parent 2aa4abe commit 49ae83f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,14 @@ static struct sk_buff *napi_skb_cache_get(void)
struct napi_alloc_cache *nc = this_cpu_ptr(&napi_alloc_cache);
struct sk_buff *skb;

if (unlikely(!nc->skb_count))
if (unlikely(!nc->skb_count)) {
nc->skb_count = kmem_cache_alloc_bulk(skbuff_head_cache,
GFP_ATOMIC,
NAPI_SKB_CACHE_BULK,
nc->skb_cache);
if (unlikely(!nc->skb_count))
return NULL;
if (unlikely(!nc->skb_count))
return NULL;
}

skb = nc->skb_cache[--nc->skb_count];
kasan_unpoison_object_data(skbuff_head_cache, skb);
Expand Down

0 comments on commit 49ae83f

Please sign in to comment.