summaryrefslogtreecommitdiff
path: root/kernel/bpf/btf.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2024-08-13 14:34:10 -0700
committerAndrii Nakryiko <andrii@kernel.org>2024-08-13 15:58:21 -0700
commiteb80ee85801cd8e3c6f39b08830867d2afecd8f5 (patch)
tree3abca875766b873d4b0a10b97942a9bd21f3c43e /kernel/bpf/btf.c
parent55f325958ccc41eaea43eb4546d4dc77c1b5ef8a (diff)
bpf: trivial conversions for fdget()
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> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Diffstat (limited to 'kernel/bpf/btf.c')
-rw-r--r--kernel/bpf/btf.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index e34f58abc7e2..c4506d788c85 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -7676,21 +7676,16 @@ int btf_new_fd(const union bpf_attr *attr, bpfptr_t uattr, u32 uattr_size)
struct btf *btf_get_by_fd(int fd)
{
struct btf *btf;
- struct fd f;
+ CLASS(fd, f)(fd);
- f = fdget(fd);
-
- if (!fd_file(f))
+ if (fd_empty(f))
return ERR_PTR(-EBADF);
- if (fd_file(f)->f_op != &btf_fops) {
- fdput(f);
+ if (fd_file(f)->f_op != &btf_fops)
return ERR_PTR(-EINVAL);
- }
btf = fd_file(f)->private_data;
refcount_inc(&btf->refcnt);
- fdput(f);
return btf;
}