aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/vhost/net.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/vhost/net.c')
-rw-r--r--drivers/vhost/net.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index ad37da2b6cb5..9777583218ff 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -17,6 +17,7 @@
17#include <linux/workqueue.h> 17#include <linux/workqueue.h>
18#include <linux/rcupdate.h> 18#include <linux/rcupdate.h>
19#include <linux/file.h> 19#include <linux/file.h>
20#include <linux/slab.h>
20 21
21#include <linux/net.h> 22#include <linux/net.h>
22#include <linux/if_packet.h> 23#include <linux/if_packet.h>
@@ -125,7 +126,7 @@ static void handle_tx(struct vhost_net *net)
125 mutex_lock(&vq->mutex); 126 mutex_lock(&vq->mutex);
126 vhost_disable_notify(vq); 127 vhost_disable_notify(vq);
127 128
128 if (wmem < sock->sk->sk_sndbuf * 2) 129 if (wmem < sock->sk->sk_sndbuf / 2)
129 tx_poll_stop(net); 130 tx_poll_stop(net);
130 hdr_size = vq->hdr_size; 131 hdr_size = vq->hdr_size;
131 132
@@ -508,12 +509,12 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
508 /* Verify that ring has been setup correctly. */ 509 /* Verify that ring has been setup correctly. */
509 if (!vhost_vq_access_ok(vq)) { 510 if (!vhost_vq_access_ok(vq)) {
510 r = -EFAULT; 511 r = -EFAULT;
511 goto err; 512 goto err_vq;
512 } 513 }
513 sock = get_socket(fd); 514 sock = get_socket(fd);
514 if (IS_ERR(sock)) { 515 if (IS_ERR(sock)) {
515 r = PTR_ERR(sock); 516 r = PTR_ERR(sock);
516 goto err; 517 goto err_vq;
517 } 518 }
518 519
519 /* start polling new socket */ 520 /* start polling new socket */
@@ -524,12 +525,14 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
524 vhost_net_disable_vq(n, vq); 525 vhost_net_disable_vq(n, vq);
525 rcu_assign_pointer(vq->private_data, sock); 526 rcu_assign_pointer(vq->private_data, sock);
526 vhost_net_enable_vq(n, vq); 527 vhost_net_enable_vq(n, vq);
527 mutex_unlock(&vq->mutex);
528done: 528done:
529 if (oldsock) { 529 if (oldsock) {
530 vhost_net_flush_vq(n, index); 530 vhost_net_flush_vq(n, index);
531 fput(oldsock->file); 531 fput(oldsock->file);
532 } 532 }
533
534err_vq:
535 mutex_unlock(&vq->mutex);
533err: 536err:
534 mutex_unlock(&n->dev.mutex); 537 mutex_unlock(&n->dev.mutex);
535 return r; 538 return r;