mirror of
https://github.com/netdata/libbpf.git
synced 2026-03-20 16:29:07 +08:00
libbpf: avoid NULL deref when initializing map BTF info
If BPF object doesn't have an BTF info, don't attempt to search for BTF
types describing BPF map key or value layout.
Fixes: 262cfb74ffda ("libbpf: Init btf_{key,value}_type_id on internal map open")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
This commit is contained in:
committed by
Andrii Nakryiko
parent
f1b6bc31a5
commit
7db9ce5fda
@@ -4197,6 +4197,9 @@ static int bpf_map_find_btf_info(struct bpf_object *obj, struct bpf_map *map)
|
||||
__u32 key_type_id = 0, value_type_id = 0;
|
||||
int ret;
|
||||
|
||||
if (!obj->btf)
|
||||
return -ENOENT;
|
||||
|
||||
/* if it's BTF-defined map, we don't need to search for type IDs.
|
||||
* For struct_ops map, it does not need btf_key_type_id and
|
||||
* btf_value_type_id.
|
||||
|
||||
Reference in New Issue
Block a user