From: Yicong Yang yangyicong@hisilicon.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8MEWF CVE: NA
--------------------------------
ASan complains one memory leakage issue: ==2266938==ERROR: LeakSanitizer: detected memory leaks Direct leak of 14821 byte(s) in 217 object(s) allocated from: #0 0xffff96712468 in realloc (libasan.so.6+0xa5468) #1 0xffff956b0dac (/usr/lib64/libc.so.6+0x73dac) #2 0xffff9573097c in __asprintf_chk (/usr/lib64/libc.so.6+0xf397c) #3 0x4de620 in asprintf usr/include/aarch64-linux-gnu/bits/stdio2.h:178 #4 0x4de620 in print_sdt_events util/parse-events.c:2669 #5 0x4432e0 in cmd_list work/tools/perf/builtin-list.c:87 #6 0x4b85c4 in run_builtin work/tools/perf/perf.c:312 #7 0x431a90 in handle_internal_command work/tools/perf/perf.c:364 #8 0x431a90 in run_argv work/tools/perf/perf.c:408 #9 0x431a90 in main work/tools/perf/perf.c:538 #10 0xffff95667ff8 (/usr/lib64/libc.so.6+0x2aff8) #11 0xffff956680c4 in __libc_start_main (/usr/lib64/libc.so.6+0x2b0c4) #12 0x431d3c (/tmp/perf_asan+0x431d3c) SUMMARY: AddressSanitizer: 14821 byte(s) leaked in 217 allocation(s).
Fix this.
Fixes: 40218daea1db ("perf list: Show SDT and pre-cached events") Signed-off-by: Yicong Yang yangyicong@hisilicon.com Signed-off-by: Junhao He hejunhao3@huawei.com --- tools/perf/util/parse-events.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 64d148f6032c..722aaf7a40c8 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -2637,13 +2637,12 @@ void print_sdt_events(const char *subsys_glob, const char *event_glob, struct probe_cache *pcache; struct probe_cache_entry *ent; struct strlist *bidlist, *sdtlist; - struct strlist_config cfg = {.dont_dupstr = true}; - struct str_node *nd, *nd2; char *buf, *path, *ptr = NULL; + struct str_node *nd, *nd2; bool show_detail = false; int ret;
- sdtlist = strlist__new(NULL, &cfg); + sdtlist = strlist__new(NULL, NULL); if (!sdtlist) { pr_debug("Failed to allocate new strlist for SDT\n"); return; @@ -2670,6 +2669,8 @@ void print_sdt_events(const char *subsys_glob, const char *event_glob, ent->pev.event, nd->s); if (ret > 0) strlist__add(sdtlist, buf); + + free(buf); } probe_cache__delete(pcache); }