Skip to contentSkip to conversation

libbpf: Add NULL check to add_dummy_ksym_var

PATCH Applied Ian Rogers 2 participants 2 messages May 4, 2021 – May 5, 2021

Subsystems (4)
lore
Share & tools
lore

Ian Rogers

author
#0 lore raw

PATCH 1/1 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 5bd022ec01f0 (libbpf: Support extern kernel function)
---
 tools/lib/bpf/libbpf.c | 3 +++
 1 file changed, 3 insertions(+)
tools/lib/bpf/libbpf.c +3 -0
index de9a5b0118fe..97d9a1c2d680 100644
@@ -3216,6 +3216,9 @@ static int add_dummy_ksym_var(struct btf *btf)
 	const struct btf_var_secinfo *vs;
 	const struct btf_type *sec;
 
+	if (!btf)
+		return 0;
+
 	sec_btf_id = btf__find_by_name_kind(btf, KSYMS_SEC,
 					    BTF_KIND_DATASEC);
 	if (sec_btf_id < 0)
Signature · 1 line
2.31.1.607.g51e8a6a459-goog
#1 lore raw
This patch was applied to bpf/bpf.git (refs/heads/master):

Hello:

This patch was applied to bpf/bpf.git (refs/heads/master):

Quoted 9 lines · On Tue, 4 May 2021 16:49:10 -0700 you wrote:

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

Fixes 5bd022ec01f0 (libbpf: Support extern kernel function)

[...]

Here is the summary with links:
- libbpf: Add NULL check to add_dummy_ksym_var

    https://git.kernel.org/bpf/bpf/c/9683e5775c75

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html