lkml.org 
[lkml]   [2017]   [Apr]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] perf evsel: Fix to perf-stat malloc corruption on arm64 platforms
Date
In some cases, ncpus used for perf_evsel__alloc_fd and for
perf_evsel__close are not the same, this is causing memory
overwrite/corruption.

Fixing issue by using same ncpus in perf_evsel__alloc_fd.

This bug is more evident on arm64 platforms, which uses
cpu_map(cpus) for PMU core devices.

Signed-off-by: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
---
tools/perf/util/evsel.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index ac59710..0dc94d7 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1489,7 +1489,9 @@ int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
nthreads = threads->nr;

if (evsel->fd == NULL &&
- perf_evsel__alloc_fd(evsel, cpus->nr, nthreads) < 0)
+ perf_evsel__alloc_fd(evsel,
+ evsel->cpus ? evsel->cpus->nr : cpus->nr,
+ nthreads) < 0)
return -ENOMEM;

if (evsel->cgrp) {
--
1.8.1.4
\
 
 \ /
  Last update: 2017-04-26 11:55    [W:0.068 / U:0.560 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site