Skip to content

Commit 301b195

Browse files
nelhageacmel
authored andcommitted
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>
1 parent 6581f6e commit 301b195

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎tools/perf/util/evlist.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,10 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist,
447447
evlist->mmap[idx].mask = mask;
448448
evlist->mmap[idx].base = mmap(NULL, evlist->mmap_len, prot,
449449
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;
451452
return -1;
453+
}
452454

453455
perf_evlist__add_pollfd(evlist, fd);
454456
return 0;

0 commit comments

Comments
 (0)