Skip to content

Commit 1d0027d

Browse files
author
Al Viro
committed
bpf: switch to fdget_raw()
Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 96e85e9 commit 1d0027d

1 file changed

Lines changed: 15 additions & 23 deletions

File tree

kernel/bpf/bpf_inode_storage.c

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -84,39 +84,33 @@ void bpf_inode_storage_free(struct inode *inode)
8484
static void *bpf_fd_inode_storage_lookup_elem(struct bpf_map *map, void *key)
8585
{
8686
struct bpf_local_storage_data *sdata;
87-
struct file *f;
88-
int fd;
87+
struct fd f = fdget_raw(*(int *)key);
8988

90-
fd = *(int *)key;
91-
f = fget_raw(fd);
92-
if (!f)
89+
if (!f.file)
9390
return ERR_PTR(-EBADF);
9491

95-
sdata = inode_storage_lookup(f->f_inode, map, true);
96-
fput(f);
92+
sdata = inode_storage_lookup(file_inode(f.file), map, true);
93+
fdput(f);
9794
return sdata ? sdata->data : NULL;
9895
}
9996

10097
static int bpf_fd_inode_storage_update_elem(struct bpf_map *map, void *key,
10198
void *value, u64 map_flags)
10299
{
103100
struct bpf_local_storage_data *sdata;
104-
struct file *f;
105-
int fd;
101+
struct fd f = fdget_raw(*(int *)key);
106102

107-
fd = *(int *)key;
108-
f = fget_raw(fd);
109-
if (!f)
103+
if (!f.file)
110104
return -EBADF;
111-
if (!inode_storage_ptr(f->f_inode)) {
112-
fput(f);
105+
if (!inode_storage_ptr(file_inode(f.file))) {
106+
fdput(f);
113107
return -EBADF;
114108
}
115109

116-
sdata = bpf_local_storage_update(f->f_inode,
110+
sdata = bpf_local_storage_update(file_inode(f.file),
117111
(struct bpf_local_storage_map *)map,
118112
value, map_flags, GFP_ATOMIC);
119-
fput(f);
113+
fdput(f);
120114
return PTR_ERR_OR_ZERO(sdata);
121115
}
122116

@@ -135,16 +129,14 @@ static int inode_storage_delete(struct inode *inode, struct bpf_map *map)
135129

136130
static int bpf_fd_inode_storage_delete_elem(struct bpf_map *map, void *key)
137131
{
138-
struct file *f;
139-
int fd, err;
132+
struct fd f = fdget_raw(*(int *)key);
133+
int err;
140134

141-
fd = *(int *)key;
142-
f = fget_raw(fd);
143-
if (!f)
135+
if (!f.file)
144136
return -EBADF;
145137

146-
err = inode_storage_delete(f->f_inode, map);
147-
fput(f);
138+
err = inode_storage_delete(file_inode(f.file), map);
139+
fdput(f);
148140
return err;
149141
}
150142

0 commit comments

Comments
 (0)