Skip to content

Commit a8fee96

Browse files
anakryikoAlexei Starovoitov
authored andcommitted
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: 262cfb7 ("libbpf: Init btf_{key,value}_type_id on internal map open") Signed-off-by: Andrii Nakryiko <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Yonghong Song <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 9492450 commit a8fee96

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

tools/lib/bpf/libbpf.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4197,6 +4197,9 @@ static int bpf_map_find_btf_info(struct bpf_object *obj, struct bpf_map *map)
41974197
__u32 key_type_id = 0, value_type_id = 0;
41984198
int ret;
41994199

4200+
if (!obj->btf)
4201+
return -ENOENT;
4202+
42004203
/* if it's BTF-defined map, we don't need to search for type IDs.
42014204
* For struct_ops map, it does not need btf_key_type_id and
42024205
* btf_value_type_id.

0 commit comments

Comments
 (0)