perf evlist: Fix errno value reporting on failed mmap
authorNelson Elhage <nelhage@nelhage.com>
Mon, 19 Dec 2011 13:39:30 +0000 (08:39 -0500)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 20 Dec 2011 15:31:15 +0000 (13:31 -0200)
commit301b195db179241da8be25f345f3c4e64960f1d5
treee397341c3247337926dc970a15ead09f1136679c
parent6581f6e35f7d0338f699fce660adb48e863f2b59
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>
tools/perf/util/evlist.c