aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/vhost
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/vhost')
-rw-r--r--drivers/vhost/net.c11
-rw-r--r--drivers/vhost/vhost.c19
2 files changed, 20 insertions, 10 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;
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 7cd55e078794..5be11c99e18f 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -22,6 +22,7 @@
22#include <linux/poll.h> 22#include <linux/poll.h>
23#include <linux/file.h> 23#include <linux/file.h>
24#include <linux/highmem.h> 24#include <linux/highmem.h>
25#include <linux/slab.h>
25 26
26#include <linux/net.h> 27#include <linux/net.h>
27#include <linux/if_packet.h> 28#include <linux/if_packet.h>
@@ -476,8 +477,10 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
476 if (r < 0) 477 if (r < 0)
477 break; 478 break;
478 eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd); 479 eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
479 if (IS_ERR(eventfp)) 480 if (IS_ERR(eventfp)) {
480 return PTR_ERR(eventfp); 481 r = PTR_ERR(eventfp);
482 break;
483 }
481 if (eventfp != vq->kick) { 484 if (eventfp != vq->kick) {
482 pollstop = filep = vq->kick; 485 pollstop = filep = vq->kick;
483 pollstart = vq->kick = eventfp; 486 pollstart = vq->kick = eventfp;
@@ -489,8 +492,10 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
489 if (r < 0) 492 if (r < 0)
490 break; 493 break;
491 eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd); 494 eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
492 if (IS_ERR(eventfp)) 495 if (IS_ERR(eventfp)) {
493 return PTR_ERR(eventfp); 496 r = PTR_ERR(eventfp);
497 break;
498 }
494 if (eventfp != vq->call) { 499 if (eventfp != vq->call) {
495 filep = vq->call; 500 filep = vq->call;
496 ctx = vq->call_ctx; 501 ctx = vq->call_ctx;
@@ -505,8 +510,10 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
505 if (r < 0) 510 if (r < 0)
506 break; 511 break;
507 eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd); 512 eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
508 if (IS_ERR(eventfp)) 513 if (IS_ERR(eventfp)) {
509 return PTR_ERR(eventfp); 514 r = PTR_ERR(eventfp);
515 break;
516 }
510 if (eventfp != vq->error) { 517 if (eventfp != vq->error) {
511 filep = vq->error; 518 filep = vq->error;
512 vq->error = eventfp; 519 vq->error = eventfp;