diff options
author | Eric Biggers <ebiggers@google.com> | 2018-01-07 01:52:20 +0300 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2018-02-01 17:26:47 +0300 |
commit | 09f332a589232f524b579ba4319433dcc7c0ed32 (patch) | |
tree | a280bfaf451d7b2c6285ae69a722851789714ae6 /drivers/vhost | |
parent | e050c7d93f4adb2a651711e2d4e0a86d41b9d76f (diff) | |
download | linux-09f332a589232f524b579ba4319433dcc7c0ed32.tar.xz |
vhost: don't hold onto file pointer for VHOST_SET_VRING_ERR
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->error.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'drivers/vhost')
-rw-r--r-- | drivers/vhost/vhost.c | 18 | ||||
-rw-r--r-- | drivers/vhost/vhost.h | 1 |
2 files changed, 4 insertions, 15 deletions
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 7bf0b734ae70..40a72d15361f 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -318,7 +318,6 @@ static void vhost_vq_reset(struct vhost_dev *dev, vq->acked_features = 0; vq->log_base = NULL; vq->error_ctx = NULL; - vq->error = NULL; vq->kick = NULL; vq->call_ctx = NULL; vq->log_ctx = NULL; @@ -616,8 +615,6 @@ void vhost_dev_cleanup(struct vhost_dev *dev) for (i = 0; i < dev->nvqs; ++i) { if (dev->vqs[i]->error_ctx) eventfd_ctx_put(dev->vqs[i]->error_ctx); - if (dev->vqs[i]->error) - fput(dev->vqs[i]->error); if (dev->vqs[i]->kick) fput(dev->vqs[i]->kick); if (dev->vqs[i]->call_ctx) @@ -1499,19 +1496,12 @@ long vhost_vring_ioctl(struct vhost_dev *d, int ioctl, void __user *argp) r = -EFAULT; break; } - eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd); - if (IS_ERR(eventfp)) { - r = PTR_ERR(eventfp); + ctx = f.fd == -1 ? NULL : eventfd_ctx_fdget(f.fd); + if (IS_ERR(ctx)) { + r = PTR_ERR(ctx); break; } - if (eventfp != vq->error) { - filep = vq->error; - vq->error = eventfp; - ctx = vq->error_ctx; - vq->error_ctx = eventfp ? - eventfd_ctx_fileget(eventfp) : NULL; - } else - filep = eventfp; + swap(ctx, vq->error_ctx); break; case VHOST_SET_VRING_ENDIAN: r = vhost_set_vring_endian(vq, argp); diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index 0ba877e385ac..e3c463ce3d48 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -92,7 +92,6 @@ struct vhost_virtqueue { struct vring_used __user *used; const struct vhost_umem_node *meta_iotlb[VHOST_NUM_ADDRS]; struct file *kick; - struct file *error; struct eventfd_ctx *call_ctx; struct eventfd_ctx *error_ctx; struct eventfd_ctx *log_ctx; |