Commit 783e3988544b94ff3918666b9f36866ac547fba1
Committed by
Michael S. Tsirkin
1 parent
94249369e9
Exists in
master
and in
20 other branches
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>
Showing 1 changed file with 4 additions and 3 deletions Side-by-side Diff
drivers/vhost/net.c
... | ... | @@ -213,12 +213,13 @@ |
213 | 213 | { |
214 | 214 | struct sk_buff *head; |
215 | 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 | 219 | head = skb_peek(&sk->sk_receive_queue); |
219 | - if (head) | |
220 | + if (likely(head)) | |
220 | 221 | len = head->len; |
221 | - release_sock(sk); | |
222 | + spin_unlock_irqrestore(&sk->sk_receive_queue.lock, flags); | |
222 | 223 | return len; |
223 | 224 | } |
224 | 225 |