Skip to content

Commit 51a1ca9

Browse files
Al Viroanakryiko
authored andcommitted
bpf: switch fdget_raw() uses to CLASS(fd_raw, ...)
Swith fdget_raw() use cases in bpf_inode_storage.c to CLASS(fd_raw). 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>
1 parent d719737 commit 51a1ca9

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

kernel/bpf/bpf_inode_storage.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,33 +78,29 @@ void bpf_inode_storage_free(struct inode *inode)
7878
static void *bpf_fd_inode_storage_lookup_elem(struct bpf_map *map, void *key)
7979
{
8080
struct bpf_local_storage_data *sdata;
81-
struct fd f = fdget_raw(*(int *)key);
81+
CLASS(fd_raw, f)(*(int *)key);
8282

83-
if (!fd_file(f))
83+
if (fd_empty(f))
8484
return ERR_PTR(-EBADF);
8585

8686
sdata = inode_storage_lookup(file_inode(fd_file(f)), map, true);
87-
fdput(f);
8887
return sdata ? sdata->data : NULL;
8988
}
9089

9190
static long bpf_fd_inode_storage_update_elem(struct bpf_map *map, void *key,
9291
void *value, u64 map_flags)
9392
{
9493
struct bpf_local_storage_data *sdata;
95-
struct fd f = fdget_raw(*(int *)key);
94+
CLASS(fd_raw, f)(*(int *)key);
9695

97-
if (!fd_file(f))
96+
if (fd_empty(f))
9897
return -EBADF;
99-
if (!inode_storage_ptr(file_inode(fd_file(f)))) {
100-
fdput(f);
98+
if (!inode_storage_ptr(file_inode(fd_file(f))))
10199
return -EBADF;
102-
}
103100

104101
sdata = bpf_local_storage_update(file_inode(fd_file(f)),
105102
(struct bpf_local_storage_map *)map,
106103
value, map_flags, GFP_ATOMIC);
107-
fdput(f);
108104
return PTR_ERR_OR_ZERO(sdata);
109105
}
110106

@@ -123,15 +119,11 @@ static int inode_storage_delete(struct inode *inode, struct bpf_map *map)
123119

124120
static long bpf_fd_inode_storage_delete_elem(struct bpf_map *map, void *key)
125121
{
126-
struct fd f = fdget_raw(*(int *)key);
127-
int err;
122+
CLASS(fd_raw, f)(*(int *)key);
128123

129-
if (!fd_file(f))
124+
if (fd_empty(f))
130125
return -EBADF;
131-
132-
err = inode_storage_delete(file_inode(fd_file(f)), map);
133-
fdput(f);
134-
return err;
126+
return inode_storage_delete(file_inode(fd_file(f)), map);
135127
}
136128

137129
/* *gfp_flags* is a hidden argument provided by the verifier */

0 commit comments

Comments
 (0)