diff options
author | Paolo Abeni <pabeni@redhat.com> | 2017-06-14 12:48:48 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-06-14 22:23:51 +0300 |
commit | 7608894e43d071ef2322a01c79522954c070ac6c (patch) | |
tree | 0648fe138448f46085291c26b3a7baabfadc2e6b /net/core/skbuff.c | |
parent | 4cbf87c78950b439df599053214b09d8f7461765 (diff) | |
download | linux-7608894e43d071ef2322a01c79522954c070ac6c.tar.xz |
net: use skb_unref() in napi_consume_skb()
The commit 83ada39bb79d ("net: factor out a helper to decrement the
skb refcount") provided and used a helper for decrementing skb usage,
but I missed at least a spot for it.
This change remove some more duplicated code reusing skb_unref() in
napi_consume_skb(), too. The helper uses an additional, unneeded
unlikely(!skb) test - napi_consume_skb() already check it a few lines
above - but the compiler is smart enough to optimize the duplicated
test out.
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/skbuff.c')
-rw-r--r-- | net/core/skbuff.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 304602784c3b..c4d2c1f824bb 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -817,10 +817,9 @@ void napi_consume_skb(struct sk_buff *skb, int budget) return; } - if (likely(atomic_read(&skb->users) == 1)) - smp_rmb(); - else if (likely(!atomic_dec_and_test(&skb->users))) + if (!skb_unref(skb)) return; + /* if reaching here SKB is ready to free */ trace_consume_skb(skb); |