Skip to content

Commit

Permalink
vhost: lock receive queue, not the socket
Browse files Browse the repository at this point in the history
vhost takes a sock lock to try and prevent
the skb from being pulled from the receive queue
after skb_peek.  However this is not the right lock to use for that,
sk_receive_queue.lock is. Fix that up.

Signed-off-by: Michael S. Tsirkin <[email protected]>
  • Loading branch information
jasowang authored and mstsirkin committed Mar 13, 2011
1 parent 9424936 commit 783e398
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/vhost/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,13 @@ static int peek_head_len(struct sock *sk)
{
struct sk_buff *head;
int len = 0;
unsigned long flags;

lock_sock(sk);
spin_lock_irqsave(&sk->sk_receive_queue.lock, flags);
head = skb_peek(&sk->sk_receive_queue);
if (head)
if (likely(head))
len = head->len;
release_sock(sk);
spin_unlock_irqrestore(&sk->sk_receive_queue.lock, flags);
return len;
}

Expand Down

0 comments on commit 783e398

Please sign in to comment.