summaryrefslogtreecommitdiff
path: root/fs/io_uring.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2022-06-04 18:52:00 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2022-06-04 18:52:00 -0700
commitdbe0ee46614016146c1b3e1fc063b44333bb2401 (patch)
treed575d487d306a8f03cceac3f930d7fd53a6079f8 /fs/io_uring.c
parentd66016c5cd3d4c474cd24622c511dcd358645613 (diff)
parent6319194ec57b0452dcda4589d24c4e7db299c5bf (diff)
Merge tag 'pull-18-rc1-work.fd' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull file descriptor updates from Al Viro. - Descriptor handling cleanups * tag 'pull-18-rc1-work.fd' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: Unify the primitives for file descriptor closing fs: remove fget_many and fput_many interface io_uring_enter(): don't leave f.flags uninitialized
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r--fs/io_uring.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 2a9b9a24fc22..86f9df56526b 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -6039,13 +6039,10 @@ static int io_close(struct io_kiocb *req, unsigned int issue_flags)
return -EAGAIN;
}
- ret = __close_fd_get_file(close->fd, &file);
+ file = __close_fd_get_file(close->fd);
spin_unlock(&files->file_lock);
- if (ret < 0) {
- if (ret == -ENOENT)
- ret = -EBADF;
+ if (!file)
goto err;
- }
/* No ->flush() or already async, safely close from here */
ret = filp_close(file, current->files);
@@ -12053,14 +12050,14 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit,
return -EINVAL;
fd = array_index_nospec(fd, IO_RINGFD_REG_MAX);
f.file = tctx->registered_rings[fd];
- if (unlikely(!f.file))
- return -EBADF;
+ f.flags = 0;
} else {
f = fdget(fd);
- if (unlikely(!f.file))
- return -EBADF;
}
+ if (unlikely(!f.file))
+ return -EBADF;
+
ret = -EOPNOTSUPP;
if (unlikely(f.file->f_op != &io_uring_fops))
goto out_fput;
@@ -12158,8 +12155,7 @@ iopoll_locked:
out:
percpu_ref_put(&ctx->refs);
out_fput:
- if (!(flags & IORING_ENTER_REGISTERED_RING))
- fdput(f);
+ fdput(f);
return ret;
}