Rely on the fd exit path machinery.

Signed-off-by: Christian Brauner (Amutable) <[email protected]>
---
 drivers/xen/gntdev-dmabuf.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/xen/gntdev-dmabuf.c b/drivers/xen/gntdev-dmabuf.c
index 83b0df460894..a3ecc7c83974 100644
--- a/drivers/xen/gntdev-dmabuf.c
+++ b/drivers/xen/gntdev-dmabuf.c
@@ -357,10 +357,10 @@ static int dmabuf_exp_from_pages(struct 
gntdev_dmabuf_export_args *args)
 {
        DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
        struct gntdev_dmabuf *gntdev_dmabuf __free(kfree) = NULL;
-       CLASS(get_unused_fd, ret)(O_CLOEXEC);
+       const struct fd_slot *fd = fd_prepare(O_CLOEXEC);
 
-       if (ret < 0)
-               return ret;
+       if (IS_ERR(fd))
+               return PTR_ERR(fd);
 
        gntdev_dmabuf = kzalloc_obj(*gntdev_dmabuf);
        if (!gntdev_dmabuf)
@@ -388,17 +388,17 @@ static int dmabuf_exp_from_pages(struct 
gntdev_dmabuf_export_args *args)
        if (IS_ERR(gntdev_dmabuf->dmabuf))
                return PTR_ERR(gntdev_dmabuf->dmabuf);
 
-       gntdev_dmabuf->fd = ret;
-       args->fd = ret;
+       gntdev_dmabuf->fd = fd_prepare_fd(fd);
+       args->fd = fd_prepare_fd(fd);
 
-       pr_debug("Exporting DMA buffer with fd %d\n", ret);
+       pr_debug("Exporting DMA buffer with fd %d\n", fd_prepare_fd(fd));
 
        get_file(gntdev_dmabuf->priv->filp);
        mutex_lock(&args->dmabuf_priv->lock);
        list_add(&gntdev_dmabuf->next, &args->dmabuf_priv->exp_list);
        mutex_unlock(&args->dmabuf_priv->lock);
 
-       fd_install(take_fd(ret), no_free_ptr(gntdev_dmabuf)->dmabuf->file);
+       fd_stage(fd, no_free_ptr(gntdev_dmabuf)->dmabuf->file);
        return 0;
 }
 

-- 
2.53.0


Reply via email to