Use __anon_inode_getfd instead of opencoding the logic using
get_unused_fd_flags + anon_inode_getfile.

Signed-off-by: Christoph Hellwig <h...@lst.de>
---
 fs/io_uring.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 5190bfb6a6657..4104f8a45d11e 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -7709,18 +7709,11 @@ static int io_uring_get_fd(struct io_ring_ctx *ctx)
                return ret;
 #endif
 
-       ret = get_unused_fd_flags(O_RDWR | O_CLOEXEC);
+       ret = __anon_inode_getfd("[io_uring]", &io_uring_fops, ctx,
+                       O_RDWR | O_CLOEXEC, &file);
        if (ret < 0)
                goto err;
 
-       file = anon_inode_getfile("[io_uring]", &io_uring_fops, ctx,
-                                       O_RDWR | O_CLOEXEC);
-       if (IS_ERR(file)) {
-               put_unused_fd(ret);
-               ret = PTR_ERR(file);
-               goto err;
-       }
-
 #if defined(CONFIG_UNIX)
        ctx->ring_sock->file = file;
 #endif
-- 
2.26.2

Reply via email to