From 233c615cb4356fcd786f66baf304053ecaa82df5 Mon Sep 17 00:00:00 2001 From: "chengshuyi.csy" Date: Thu, 14 Apr 2022 11:01:06 +0800 Subject: [PATCH] rtrace: add rtrace_free to free rtrace object Signed-off-by: chengshuyi.csy --- .../tools/detect/net_diag/rtrace/ebpf/rtrace.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/source/tools/detect/net_diag/rtrace/ebpf/rtrace.c b/source/tools/detect/net_diag/rtrace/ebpf/rtrace.c index 48079fd2..973b1e59 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; } -- Gitee