diff options
Diffstat (limited to 'drivers/vhost')
-rw-r--r-- | drivers/vhost/net.c | 11 | ||||
-rw-r--r-- | drivers/vhost/vhost.c | 23 |
2 files changed, 24 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); | ||
528 | done: | 528 | done: |
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 | |||
534 | err_vq: | ||
535 | mutex_unlock(&vq->mutex); | ||
533 | err: | 536 | err: |
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..e69d238c5af0 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> |
@@ -235,6 +236,10 @@ static int vq_memory_access_ok(void __user *log_base, struct vhost_memory *mem, | |||
235 | int log_all) | 236 | int log_all) |
236 | { | 237 | { |
237 | int i; | 238 | int i; |
239 | |||
240 | if (!mem) | ||
241 | return 0; | ||
242 | |||
238 | for (i = 0; i < mem->nregions; ++i) { | 243 | for (i = 0; i < mem->nregions; ++i) { |
239 | struct vhost_memory_region *m = mem->regions + i; | 244 | struct vhost_memory_region *m = mem->regions + i; |
240 | unsigned long a = m->userspace_addr; | 245 | unsigned long a = m->userspace_addr; |
@@ -476,8 +481,10 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp) | |||
476 | if (r < 0) | 481 | if (r < 0) |
477 | break; | 482 | break; |
478 | eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd); | 483 | eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd); |
479 | if (IS_ERR(eventfp)) | 484 | if (IS_ERR(eventfp)) { |
480 | return PTR_ERR(eventfp); | 485 | r = PTR_ERR(eventfp); |
486 | break; | ||
487 | } | ||
481 | if (eventfp != vq->kick) { | 488 | if (eventfp != vq->kick) { |
482 | pollstop = filep = vq->kick; | 489 | pollstop = filep = vq->kick; |
483 | pollstart = vq->kick = eventfp; | 490 | pollstart = vq->kick = eventfp; |
@@ -489,8 +496,10 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp) | |||
489 | if (r < 0) | 496 | if (r < 0) |
490 | break; | 497 | break; |
491 | eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd); | 498 | eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd); |
492 | if (IS_ERR(eventfp)) | 499 | if (IS_ERR(eventfp)) { |
493 | return PTR_ERR(eventfp); | 500 | r = PTR_ERR(eventfp); |
501 | break; | ||
502 | } | ||
494 | if (eventfp != vq->call) { | 503 | if (eventfp != vq->call) { |
495 | filep = vq->call; | 504 | filep = vq->call; |
496 | ctx = vq->call_ctx; | 505 | ctx = vq->call_ctx; |
@@ -505,8 +514,10 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp) | |||
505 | if (r < 0) | 514 | if (r < 0) |
506 | break; | 515 | break; |
507 | eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd); | 516 | eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd); |
508 | if (IS_ERR(eventfp)) | 517 | if (IS_ERR(eventfp)) { |
509 | return PTR_ERR(eventfp); | 518 | r = PTR_ERR(eventfp); |
519 | break; | ||
520 | } | ||
510 | if (eventfp != vq->error) { | 521 | if (eventfp != vq->error) { |
511 | filep = vq->error; | 522 | filep = vq->error; |
512 | vq->error = eventfp; | 523 | vq->error = eventfp; |