Rely on the fd exit path machinery.

Signed-off-by: Christian Brauner (Amutable) <[email protected]>
---
 drivers/accel/habanalabs/common/memory.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/accel/habanalabs/common/memory.c 
b/drivers/accel/habanalabs/common/memory.c
index 361cff577381..1559442cd56f 100644
--- a/drivers/accel/habanalabs/common/memory.c
+++ b/drivers/accel/habanalabs/common/memory.c
@@ -1861,11 +1861,13 @@ static int export_dmabuf(struct hl_ctx *ctx,
 {
        DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
        struct hl_device *hdev = ctx->hdev;
-       CLASS(get_unused_fd, fd)(flags);
+       const struct fd_slot *fd = fd_prepare(flags);
 
-       if (fd < 0) {
-               dev_err(hdev->dev, "failed to get a file descriptor for a 
dma-buf, %d\n", fd);
-               return fd;
+       if (IS_ERR(fd)) {
+               int rc = PTR_ERR(fd);
+
+               dev_err(hdev->dev, "failed to get a file descriptor for a 
dma-buf, %d\n", rc);
+               return rc;
        }
 
        exp_info.ops = &habanalabs_dmabuf_ops;
@@ -1889,8 +1891,7 @@ static int export_dmabuf(struct hl_ctx *ctx,
         */
        get_file(ctx->hpriv->file_priv->filp);
 
-       *dmabuf_fd = fd;
-       fd_install(take_fd(fd), hl_dmabuf->dmabuf->file);
+       *dmabuf_fd = fd_stage(fd, hl_dmabuf->dmabuf->file);
 
        return 0;
 }

-- 
2.53.0


Reply via email to