mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-17 02:36:21 +00:00
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>
This commit is contained in:
parent
0ede61d858
commit
50d910d273
@ -220,7 +220,6 @@ int io_close(struct io_kiocb *req, unsigned int issue_flags)
|
|||||||
{
|
{
|
||||||
struct files_struct *files = current->files;
|
struct files_struct *files = current->files;
|
||||||
struct io_close *close = io_kiocb_to_cmd(req, struct io_close);
|
struct io_close *close = io_kiocb_to_cmd(req, struct io_close);
|
||||||
struct fdtable *fdt;
|
|
||||||
struct file *file;
|
struct file *file;
|
||||||
int ret = -EBADF;
|
int ret = -EBADF;
|
||||||
|
|
||||||
@ -230,13 +229,7 @@ int io_close(struct io_kiocb *req, unsigned int issue_flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
spin_lock(&files->file_lock);
|
spin_lock(&files->file_lock);
|
||||||
fdt = files_fdtable(files);
|
file = files_lookup_fd_locked(files, close->fd);
|
||||||
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));
|
|
||||||
if (!file || io_is_uring_fops(file)) {
|
if (!file || io_is_uring_fops(file)) {
|
||||||
spin_unlock(&files->file_lock);
|
spin_unlock(&files->file_lock);
|
||||||
goto err;
|
goto err;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user