Perf fix two memory leakage
Subsystems (2)
cover Perf fix two memory leakage
From: Yicong Yang <[email protected]>
ASan reports two memory leakage in the raw trace dump mode perf report -D. One is in the framework and can be reproduced when using hisi_ptt and arm_spe, which is fixed in Patch 1/2. Another is in the hisi_ptt parser and fixed in Patch 2/2.
Yicong Yang (2):
perf header: Fix one memory leakage in
perf_event__fprintf_event_update()
perf hisi-ptt: Fix one memory leakage in
hisi_ptt_process_auxtrace_event()
tools/perf/util/header.c | 5 +++-- tools/perf/util/hisi-ptt.c | 1 + 2 files changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.24.0
PATCH 1/2 perf header: Fix one memory leakage in perf_event__fprintf_event_update()
From: Yicong Yang <[email protected]>
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.
--- tools/perf/util/header.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/perf/util/header.c +3 -2
@@ -4369,9 +4369,10 @@ 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 :
Signature · 1 line
2.24.0
Re: [PATCH 1/2] perf header: Fix one memory leakage in perf_event__fprintf_event_update()
Hello,
Quoted 9 lines · Yicong Yang
From: Yicong Yang <[email protected]>
When dump the raw trace by
perf report -DASan reports a memory leakage inperf_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.
Quoted 3 lines
Fixes c853f9394b7b ("perf tools: Add perf_event__fprintf_event_update function")Cc Jiri Olsa <[email protected]>Signed-off-by Yicong Yang <[email protected]>
Thanks,
Namhyung
Quoted 25 lines
--- tools/perf/util/header.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)tools/perf/util/header.c +3
-3@@ -4369,9 +4369,10 @@ 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 : --2.24.0
PATCH 2/2 perf hisi-ptt: Fix one memory leakage in hisi_ptt_process_auxtrace_event()
In reply to Yicong YangFrom: Yicong Yang <[email protected]>
ASan complains a memory leakage in hisi_ptt_process_auxtrace_event() that the data buffer is not freed. Since currently we only support the raw dump trace mode, the data buffer is used only within this function. So fix this by freeing the data buffer before going out.
--- tools/perf/util/hisi-ptt.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/hisi-ptt.c +1 -0
@@ -123,6 +123,7 @@ static int hisi_ptt_process_auxtrace_event(struct perf_session *session,if (dump_trace)hisi_ptt_dump_event (ptt, data, size); +free (data);return 0 ; }
Signature · 1 line
2.24.0
Re: [PATCH 2/2] perf hisi-ptt: Fix one memory leakage in hisi_ptt_process_auxtrace_event()
Quoted 10 lines · Yicong Yang
From: Yicong Yang <[email protected]>
ASan complains a memory leakage in
hisi_ptt_process_auxtrace_event()that the data buffer is not freed. Since currently we only support the raw dump trace mode, the data buffer is used only within this function. So fix this by freeing the data buffer before going out.Fixes 5e91e57e6809 ("perf auxtrace arm64: Add support for parsing HiSilicon PCIe Trace packet")Signed-off-by Yicong Yang <[email protected]>
Thanks,
Namhyung
Quoted 20 lines
--- tools/perf/util/hisi-ptt.c | 1 + 1 file changed, 1 insertion(+)tools/perf/util/hisi-ptt.c +1
-1@@ -123,6 +123,7 @@ static int hisi_ptt_process_auxtrace_event(struct perf_session *session,if (dump_trace)hisi_ptt_dump_event (ptt, data, size); +free (data);return 0 ; } --2.24.0
Quoted 14 lines · Yicong Yang
From: Yicong Yang <[email protected]>
ASan reports two memory leakage in the raw trace dump mode
perf report -D. One is in the framework and can be reproduced when usinghisi_pttandarm_spe, which is fixed in Patch 1/2. Another is in thehisi_pttparser and fixed in Patch 2/2.Yicong Yang (2):
perf header: Fix one memory leakage in
perf_event__fprintf_event_update()
perf hisi-ptt: Fix one memory leakage in
hisi_ptt_process_auxtrace_event()
Quoted 3 lines
tools/perf/util/header.c | 5 +++-- tools/perf/util/hisi-ptt.c | 1 + 2 files changed, 4 insertions(+), 2 deletions(-)
The series:
Thanks,
Ian
Quoted 3 lines
--
2.24.0