diff options
author | Eric Biggers <ebiggers@google.com> | 2018-01-06 17:52:19 -0500 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2018-02-01 09:26:46 -0500 |
commit | e050c7d93f4adb2a651711e2d4e0a86d41b9d76f (patch) | |
tree | 9e9e3387eadf9365189c35bdeec2b653419d2440 | |
parent | 03ee47ae8a7c608975be7e45287bff0482e295d6 (diff) |
vhost: don't hold onto file pointer for VHOST_SET_VRING_CALL
We already hold a reference to the eventfd_ctx, which is sufficient;
there's no need to hold a reference to the struct file as well. So get
rid of vhost_virtqueue->call.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Jason Wang <jasowang@redhat.com>
-rw-r--r-- | drivers/vhost/vhost.c | 20 | ||||
-rw-r--r-- | drivers/vhost/vhost.h | 1 |
2 files changed, 5 insertions, 16 deletions
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index e5eba5acfd55..7bf0b734ae70 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c | |||
@@ -321,7 +321,6 @@ static void vhost_vq_reset(struct vhost_dev *dev, | |||
321 | vq->error = NULL; | 321 | vq->error = NULL; |
322 | vq->kick = NULL; | 322 | vq->kick = NULL; |
323 | vq->call_ctx = NULL; | 323 | vq->call_ctx = NULL; |
324 | vq->call = NULL; | ||
325 | vq->log_ctx = NULL; | 324 | vq->log_ctx = NULL; |
326 | vhost_reset_is_le(vq); | 325 | vhost_reset_is_le(vq); |
327 | vhost_disable_cross_endian(vq); | 326 | vhost_disable_cross_endian(vq); |
@@ -623,8 +622,6 @@ void vhost_dev_cleanup(struct vhost_dev *dev) | |||
623 | fput(dev->vqs[i]->kick); | 622 | fput(dev->vqs[i]->kick); |
624 | if (dev->vqs[i]->call_ctx) | 623 | if (dev->vqs[i]->call_ctx) |
625 | eventfd_ctx_put(dev->vqs[i]->call_ctx); | 624 | eventfd_ctx_put(dev->vqs[i]->call_ctx); |
626 | if (dev->vqs[i]->call) | ||
627 | fput(dev->vqs[i]->call); | ||
628 | vhost_vq_reset(dev, dev->vqs[i]); | 625 | vhost_vq_reset(dev, dev->vqs[i]); |
629 | } | 626 | } |
630 | vhost_dev_free_iovecs(dev); | 627 | vhost_dev_free_iovecs(dev); |
@@ -1490,19 +1487,12 @@ long vhost_vring_ioctl(struct vhost_dev *d, int ioctl, void __user *argp) | |||
1490 | r = -EFAULT; | 1487 | r = -EFAULT; |
1491 | break; | 1488 | break; |
1492 | } | 1489 | } |
1493 | eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd); | 1490 | ctx = f.fd == -1 ? NULL : eventfd_ctx_fdget(f.fd); |
1494 | if (IS_ERR(eventfp)) { | 1491 | if (IS_ERR(ctx)) { |
1495 | r = PTR_ERR(eventfp); | 1492 | r = PTR_ERR(ctx); |
1496 | break; | 1493 | break; |
1497 | } | 1494 | } |
1498 | if (eventfp != vq->call) { | 1495 | swap(ctx, vq->call_ctx); |
1499 | filep = vq->call; | ||
1500 | ctx = vq->call_ctx; | ||
1501 | vq->call = eventfp; | ||
1502 | vq->call_ctx = eventfp ? | ||
1503 | eventfd_ctx_fileget(eventfp) : NULL; | ||
1504 | } else | ||
1505 | filep = eventfp; | ||
1506 | break; | 1496 | break; |
1507 | case VHOST_SET_VRING_ERR: | 1497 | case VHOST_SET_VRING_ERR: |
1508 | if (copy_from_user(&f, argp, sizeof f)) { | 1498 | if (copy_from_user(&f, argp, sizeof f)) { |
@@ -1549,7 +1539,7 @@ long vhost_vring_ioctl(struct vhost_dev *d, int ioctl, void __user *argp) | |||
1549 | if (pollstop && vq->handle_kick) | 1539 | if (pollstop && vq->handle_kick) |
1550 | vhost_poll_stop(&vq->poll); | 1540 | vhost_poll_stop(&vq->poll); |
1551 | 1541 | ||
1552 | if (ctx) | 1542 | if (!IS_ERR_OR_NULL(ctx)) |
1553 | eventfd_ctx_put(ctx); | 1543 | eventfd_ctx_put(ctx); |
1554 | if (filep) | 1544 | if (filep) |
1555 | fput(filep); | 1545 | fput(filep); |
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index d56b711577eb..0ba877e385ac 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h | |||
@@ -92,7 +92,6 @@ struct vhost_virtqueue { | |||
92 | struct vring_used __user *used; | 92 | struct vring_used __user *used; |
93 | const struct vhost_umem_node *meta_iotlb[VHOST_NUM_ADDRS]; | 93 | const struct vhost_umem_node *meta_iotlb[VHOST_NUM_ADDRS]; |
94 | struct file *kick; | 94 | struct file *kick; |
95 | struct file *call; | ||
96 | struct file *error; | 95 | struct file *error; |
97 | struct eventfd_ctx *call_ctx; | 96 | struct eventfd_ctx *call_ctx; |
98 | struct eventfd_ctx *error_ctx; | 97 | struct eventfd_ctx *error_ctx; |