Skip to content

Commit

Permalink
bpf, inode_storage: Put file handler if no storage was found
Browse files Browse the repository at this point in the history
[ Upstream commit b9557ca ]

Put file f if inode_storage_ptr() returns NULL.

Fixes: 8ea6368 ("bpf: Implement bpf_local_storage for inodes")
Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: KP Singh <kpsingh@kernel.org>
Link: https://lore.kernel.org/bpf/20210121020856.25507-1-bianpan2016@163.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
SinkFinder authored and gregkh committed Feb 10, 2021
1 parent 9447d0f commit 571fe1b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kernel/bpf/bpf_inode_storage.c
Expand Up @@ -125,8 +125,12 @@ static int bpf_fd_inode_storage_update_elem(struct bpf_map *map, void *key,

fd = *(int *)key;
f = fget_raw(fd);
if (!f || !inode_storage_ptr(f->f_inode))
if (!f)
return -EBADF;
if (!inode_storage_ptr(f->f_inode)) {
fput(f);
return -EBADF;
}

sdata = bpf_local_storage_update(f->f_inode,
(struct bpf_local_storage_map *)map,
Expand Down

0 comments on commit 571fe1b

Please sign in to comment.