Commit 67e9e7e1 authored by Yicong Yang's avatar Yicong Yang Committed by Junhao He
Browse files

perf header: Fix one memory leakage in perf_event__fprintf_event_update()

driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I8MEWF


CVE: NA

--------------------------------

When dump the raw trace by `perf report -D` ASan reports a memory
leakage in perf_event__fprintf_event_update(). It shows that we
allocated a temporary cpumap for dumping the CPUs but doesn't
release it and it's not used elsewhere. Fix this by free the
cpumap after the dumping.

Fixes: c853f939 ("perf tools: Add perf_event__fprintf_event_update function")
Signed-off-by: default avatarYicong Yang <yangyicong@hisilicon.com>
Signed-off-by: default avatarJunhao He <hejunhao3@huawei.com>
parent 3f1c7091
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -3970,10 +3970,12 @@ size_t perf_event__fprintf_event_update(union perf_event *event, FILE *fp)
		ret += fprintf(fp, "... ");

		map = cpu_map__new_data(&ev_cpus->cpus);
		if (map)
		if (map) {
			ret += cpu_map__fprintf(map, fp);
		else
			perf_cpu_map__put(map);
		} else {
			ret += fprintf(fp, "failed to get cpus\n");
		}
		break;
	default:
		ret += fprintf(fp, "... unknown type\n");