diff options
author | Nelson Elhage <nelhage@nelhage.com> | 2011-12-19 08:39:30 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-12-20 10:31:15 -0500 |
commit | 301b195db179241da8be25f345f3c4e64960f1d5 (patch) | |
tree | e397341c3247337926dc970a15ead09f1136679c /tools | |
parent | 6581f6e35f7d0338f699fce660adb48e863f2b59 (diff) |
perf evlist: Fix errno value reporting on failed mmap
On failure, perf_evlist__mmap_per_{cpu,thread} will try to munmap()
every map that doesn't have a NULL base. This will fail with EINVAL if
one of them has base == MAP_FAILED, clobbering errno, so that
perf_evlist__map will return EINVAL on any failure regardless of the
root cause.
Fix this by resetting failed maps to a NULL base.
Acked-by: Namhyung Kim <namhyung@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1324301972-22740-2-git-send-email-nelhage@nelhage.com
Signed-off-by: Nelson Elhage <nelhage@nelhage.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/evlist.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 8b19e7a1e881..963d63dde457 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -447,8 +447,10 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, | |||
447 | evlist->mmap[idx].mask = mask; | 447 | evlist->mmap[idx].mask = mask; |
448 | evlist->mmap[idx].base = mmap(NULL, evlist->mmap_len, prot, | 448 | evlist->mmap[idx].base = mmap(NULL, evlist->mmap_len, prot, |
449 | MAP_SHARED, fd, 0); | 449 | MAP_SHARED, fd, 0); |
450 | if (evlist->mmap[idx].base == MAP_FAILED) | 450 | if (evlist->mmap[idx].base == MAP_FAILED) { |
451 | evlist->mmap[idx].base = NULL; | ||
451 | return -1; | 452 | return -1; |
453 | } | ||
452 | 454 | ||
453 | perf_evlist__add_pollfd(evlist, fd); | 455 | perf_evlist__add_pollfd(evlist, fd); |
454 | return 0; | 456 | return 0; |