diff --git a/source/tools/detect/net_diag/rtrace/ebpf/rtrace.c b/source/tools/detect/net_diag/rtrace/ebpf/rtrace.c index 48079fd231e26905b64de34b5f542b1417550021..973b1e594b4bab7c9797bab6382cf9b857d698fc 100644 --- a/source/tools/detect/net_diag/rtrace/ebpf/rtrace.c +++ b/source/tools/detect/net_diag/rtrace/ebpf/rtrace.c @@ -84,6 +84,22 @@ int rtrace_filter_map_fd(struct rtrace *r) return bpf_map__fd(r->obj->maps.filter_map); } +static void rtrace_free(struct rtrace *r) +{ + rtrace_bpf__destroy(r->obj); + + free(r->btf); + r->btf = NULL; + + free(r->btf_custom_path); + r->btf_custom_path = NULL; + + free(r->pin_path); + r->pin_path = NULL; + + free(r); +} + static int rtrace_init(struct rtrace *r, char *btf_custom_path, char *pin_path) { int err; @@ -163,7 +179,7 @@ struct rtrace *rtrace_alloc_and_init(char *btf_custom_path, char *pin_path) return r; err_out: - // rtrace_free(r); + rtrace_free(r); return NULL; }