From 462e3f600a99fe71b51d0ed80e589e6b663c35e9 Mon Sep 17 00:00:00 2001 From: Haowen Bai Date: Thu, 7 Apr 2022 10:38:17 +0800 Subject: [PATCH] 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 Signed-off-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/1649299098-2069-1-git-send-email-baihaowen@meizu.com --- src/usdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/usdt.c b/src/usdt.c index c5acf28..bb1e886 100644 --- a/src/usdt.c +++ b/src/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)