summaryrefslogtreecommitdiff
path: root/io_uring
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2023-10-10 11:23:26 +0300
committerChristian Brauner <brauner@kernel.org>2023-10-19 12:02:49 +0300
commit50d910d27362d6809a0668f0f1cb5220bc7dc6a0 (patch)
tree5cfb2cdad606b7ad750591b0c1825f330dc8f8d6 /io_uring
parent0ede61d8589cc2d93aa78230d74ac58b5b8d0244 (diff)
downloadlinux-50d910d27362d6809a0668f0f1cb5220bc7dc6a0.tar.xz
io_uring: use files_lookup_fd_locked()
While valid we don't need to open-code rcu dereferences if we're acquiring file_lock anyway. Suggested-by: Al Viro <viro@zeniv.linux.org.uk> Link: https://lore.kernel.org/r/20231010030615.GO800259@ZenIV Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'io_uring')
-rw-r--r--io_uring/openclose.c9
1 files changed, 1 insertions, 8 deletions
diff --git a/io_uring/openclose.c b/io_uring/openclose.c
index e3fae26e025d..fb73adb89067 100644
--- a/io_uring/openclose.c
+++ b/io_uring/openclose.c
@@ -220,7 +220,6 @@ int io_close(struct io_kiocb *req, unsigned int issue_flags)
{
struct files_struct *files = current->files;
struct io_close *close = io_kiocb_to_cmd(req, struct io_close);
- struct fdtable *fdt;
struct file *file;
int ret = -EBADF;
@@ -230,13 +229,7 @@ int io_close(struct io_kiocb *req, unsigned int issue_flags)
}
spin_lock(&files->file_lock);
- fdt = files_fdtable(files);
- if (close->fd >= fdt->max_fds) {
- spin_unlock(&files->file_lock);
- goto err;
- }
- file = rcu_dereference_protected(fdt->fd[close->fd],
- lockdep_is_held(&files->file_lock));
+ file = files_lookup_fd_locked(files, close->fd);
if (!file || io_is_uring_fops(file)) {
spin_unlock(&files->file_lock);
goto err;