aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/vhost/net.c
diff options
context:
space:
mode:
authorJason Wang <jasowang@redhat.com>2011-01-17 03:11:17 -0500
committerMichael S. Tsirkin <mst@redhat.com>2011-03-13 17:08:04 -0400
commit783e3988544b94ff3918666b9f36866ac547fba1 (patch)
treee05c17f7e368490e3d34750cc2f6b8e2092ef1e5 /drivers/vhost/net.c
parent94249369e9930276e30087da205349a55478cbb5 (diff)
vhost: lock receive queue, not the socket
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 <mst@redhat.com>
Diffstat (limited to 'drivers/vhost/net.c')
-rw-r--r--drivers/vhost/net.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 0329c411bbf1..57203014c457 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -213,12 +213,13 @@ static int peek_head_len(struct sock *sk)
213{ 213{
214 struct sk_buff *head; 214 struct sk_buff *head;
215 int len = 0; 215 int len = 0;
216 unsigned long flags;
216 217
217 lock_sock(sk); 218 spin_lock_irqsave(&sk->sk_receive_queue.lock, flags);
218 head = skb_peek(&sk->sk_receive_queue); 219 head = skb_peek(&sk->sk_receive_queue);
219 if (head) 220 if (likely(head))
220 len = head->len; 221 len = head->len;
221 release_sock(sk); 222 spin_unlock_irqrestore(&sk->sk_receive_queue.lock, flags);
222 return len; 223 return len;
223} 224}
224 225