struct sk_buff *read_skb = NULL, *unread_skb = NULL;
struct unix_sock *u = unix_sk(sk);
- if (!unix_skb_len(skb)) {
- spin_lock(&sk->sk_receive_queue.lock);
+ if (likely(unix_skb_len(skb) && skb != READ_ONCE(u->oob_skb)))
+ return skb;
+ spin_lock(&sk->sk_receive_queue.lock);
+
+ if (!unix_skb_len(skb)) {
if (copied && (!u->oob_skb || skb == u->oob_skb)) {
skb = NULL;
} else if (flags & MSG_PEEK) {
__skb_unlink(read_skb, &sk->sk_receive_queue);
}
- spin_unlock(&sk->sk_receive_queue.lock);
-
- consume_skb(read_skb);
- return skb;
+ goto unlock;
}
- spin_lock(&sk->sk_receive_queue.lock);
-
if (skb != u->oob_skb)
goto unlock;
unlock:
spin_unlock(&sk->sk_receive_queue.lock);
+ consume_skb(read_skb);
kfree_skb(unread_skb);
return skb;