diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2024-07-20 02:17:58 +0200 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2024-11-03 07:28:06 +0100 |
commit | 6348be02eead77bdd1562154ed6b3296ad3b3750 (patch) | |
tree | f5d5ecda1f932e56da79fb5d6a6b5e015dd76ec1 /fs/kernel_read_file.c | |
parent | privcmd_ioeventfd_assign(): don't open-code eventfd_ctx_fdget() (diff) | |
download | linux-6348be02eead77bdd1562154ed6b3296ad3b3750.tar.xz linux-6348be02eead77bdd1562154ed6b3296ad3b3750.zip |
fdget(), trivial conversions
fdget() is the first thing done in scope, all matching fdput() are
immediately followed by leaving the scope.
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/kernel_read_file.c')
-rw-r--r-- | fs/kernel_read_file.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/fs/kernel_read_file.c b/fs/kernel_read_file.c index 9ff37ae650ea..de32c95d823d 100644 --- a/fs/kernel_read_file.c +++ b/fs/kernel_read_file.c @@ -175,15 +175,11 @@ ssize_t kernel_read_file_from_fd(int fd, loff_t offset, void **buf, size_t buf_size, size_t *file_size, enum kernel_read_file_id id) { - struct fd f = fdget(fd); - ssize_t ret = -EBADF; + CLASS(fd, f)(fd); - if (!fd_file(f) || !(fd_file(f)->f_mode & FMODE_READ)) - goto out; + if (fd_empty(f) || !(fd_file(f)->f_mode & FMODE_READ)) + return -EBADF; - ret = kernel_read_file(fd_file(f), offset, buf, buf_size, file_size, id); -out: - fdput(f); - return ret; + return kernel_read_file(fd_file(f), offset, buf, buf_size, file_size, id); } EXPORT_SYMBOL_GPL(kernel_read_file_from_fd); |