Commit 9683e577 authored by Ian Rogers's avatar Ian Rogers Committed by Andrii Nakryiko

libbpf: Add NULL check to add_dummy_ksym_var

Avoids a segv if btf isn't present. Seen on the call path
__bpf_object__open calling bpf_object__collect_externs.

Fixes: 5bd022ec (libbpf: Support extern kernel function)
Suggested-by: default avatarStanislav Fomichev <sdf@google.com>
Suggested-by: default avatarPetar Penkov <ppenkov@google.com>
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210504234910.976501-1-irogers@google.com
parent 1682d8df
...@@ -3216,6 +3216,9 @@ static int add_dummy_ksym_var(struct btf *btf) ...@@ -3216,6 +3216,9 @@ static int add_dummy_ksym_var(struct btf *btf)
const struct btf_var_secinfo *vs; const struct btf_var_secinfo *vs;
const struct btf_type *sec; const struct btf_type *sec;
if (!btf)
return 0;
sec_btf_id = btf__find_by_name_kind(btf, KSYMS_SEC, sec_btf_id = btf__find_by_name_kind(btf, KSYMS_SEC,
BTF_KIND_DATASEC); BTF_KIND_DATASEC);
if (sec_btf_id < 0) if (sec_btf_id < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment