Skip to content

Commit b9557ca

Browse files
SinkFinderborkmann
authored andcommitted
bpf, inode_storage: Put file handler if no storage was found
Put file f if inode_storage_ptr() returns NULL. Fixes: 8ea6368 ("bpf: Implement bpf_local_storage for inodes") Signed-off-by: Pan Bian <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: KP Singh <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent f4a2da7 commit b9557ca

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

kernel/bpf/bpf_inode_storage.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,12 @@ static int bpf_fd_inode_storage_update_elem(struct bpf_map *map, void *key,
125125

126126
fd = *(int *)key;
127127
f = fget_raw(fd);
128-
if (!f || !inode_storage_ptr(f->f_inode))
128+
if (!f)
129+
return -EBADF;
130+
if (!inode_storage_ptr(f->f_inode)) {
131+
fput(f);
129132
return -EBADF;
133+
}
130134

131135
sdata = bpf_local_storage_update(f->f_inode,
132136
(struct bpf_local_storage_map *)map,

0 commit comments

Comments
 (0)