aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib/bpf
diff options
context:
space:
mode:
authorHaowen Bai <baihaowen@meizu.com>2022-04-07 10:38:17 +0800
committerAndrii Nakryiko <andrii@kernel.org>2022-04-07 11:46:33 -0700
commite58c5c9717460851047f63b8615ea0760a6f3a2e (patch)
treea2d87f4383ee4e80277a07dc8be57dee3a967753 /tools/lib/bpf
parentMerge branch 'libbpf: uprobe name-based attach followups' (diff)
downloadlinux-dev-e58c5c9717460851047f63b8615ea0760a6f3a2e.tar.xz
linux-dev-e58c5c9717460851047f63b8615ea0760a6f3a2e.zip
libbpf: Potential NULL dereference in usdt_manager_attach_usdt()
link could be null but still dereference bpf_link__destroy(&link->link) and it will lead to a null pointer access. Signed-off-by: Haowen Bai <baihaowen@meizu.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/1649299098-2069-1-git-send-email-baihaowen@meizu.com
Diffstat (limited to 'tools/lib/bpf')
-rw-r--r--tools/lib/bpf/usdt.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/lib/bpf/usdt.c b/tools/lib/bpf/usdt.c
index c5acf2824fcc..bb1e88613343 100644
--- a/tools/lib/bpf/usdt.c
+++ b/tools/lib/bpf/usdt.c
@@ -1071,8 +1071,8 @@ struct bpf_link *usdt_manager_attach_usdt(struct usdt_manager *man, const struct
return &link->link;
err_out:
- bpf_link__destroy(&link->link);
-
+ if (link)
+ bpf_link__destroy(&link->link);
free(targets);
hashmap__free(specs_hash);
if (elf)