1
0
Fork 0

bpf: decrease usercnt if bpf_map_new_fd() fails in bpf_map_get_fd_by_id()

In bpf/syscall.c, bpf_map_get_fd_by_id() use bpf_map_inc_not_zero()
to increase the refcount, both map->refcnt and map->usercnt. Then, if
bpf_map_new_fd() fails, should handle map->usercnt too.

Fixes: bd5f5f4ecb ("bpf: Add BPF_MAP_GET_FD_BY_ID")
Signed-off-by: Peng Sun <sironhide0null@gmail.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
hifive-unleashed-5.1
Peng Sun 2019-02-26 22:15:37 +08:00 committed by Daniel Borkmann
parent 3da1ed7ac3
commit 781e62823c
1 changed files with 1 additions and 1 deletions

View File

@ -1986,7 +1986,7 @@ static int bpf_map_get_fd_by_id(const union bpf_attr *attr)
fd = bpf_map_new_fd(map, f_flags);
if (fd < 0)
bpf_map_put(map);
bpf_map_put_with_uref(map);
return fd;
}