From: Yicong Yang yangyicong@hisilicon.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8MEWF CVE: NA
--------------------------------
When try to open perf on an offline CPU, ASan complains: ==2316857==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 512 byte(s) in 1 object(s) allocated from: #0 0xffff9e774290 in __interceptor_calloc (libasan.so.6+0xa5290) #1 0x62b34c in affinity__setup (/tmp/perf_asan+0x62b34c) #2 0x540d70 in cmd_stat (/tmp/perf_asan+0x540d70) #3 0x59e7e4 in run_builtin (/tmp/perf_asan+0x59e7e4) #4 0x456778 in main (/tmp/perf_asan+0x456778) #5 0xffff9d9c4ff8 (/usr/lib64/libc.so.6+0x2aff8) #6 0xffff9d9c50c4 in __libc_start_main (/usr/lib64/libc.so.6+0x2b0c4) #7 0x523f60 (/tmp/perf_asan+0x523f60)
Direct leak of 512 byte(s) in 1 object(s) allocated from: #0 0xffff9e774290 in __interceptor_calloc (libasan.so.6+0xa5290) #1 0x62b370 in affinity__setup (/tmp/perf_asan+0x62b370) #2 0x540d70 in cmd_stat (/tmp/perf_asan+0x540d70) #3 0x59e7e4 in run_builtin (/tmp/perf_asan+0x59e7e4) #4 0x456778 in main (/tmp/perf_asan+0x456778) #5 0xffff9d9c4ff8 (/usr/lib64/libc.so.6+0x2aff8) #6 0xffff9d9c50c4 in __libc_start_main (/usr/lib64/libc.so.6+0x2b0c4) #7 0x523f60 (/tmp/perf_asan+0x523f60)
Fix this.
Fixes: 4804e0111662 ("perf stat: Use affinity for opening events") Signed-off-by: Yicong Yang yangyicong@hisilicon.com Signed-off-by: Junhao He hejunhao3@huawei.com --- tools/perf/builtin-stat.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 89e80a3bc9c3..1f8a23a1b867 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -768,6 +768,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
switch (stat_handle_error(counter)) { case COUNTER_FATAL: + affinity__cleanup(&affinity); return -1; case COUNTER_RETRY: goto try_again; @@ -813,6 +814,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
switch (stat_handle_error(counter)) { case COUNTER_FATAL: + affinity__cleanup(&affinity); return -1; case COUNTER_RETRY: goto try_again_reset;