lkml.org 
[lkml]   [2011]   [Dec]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 04/10] perf evlist: Fix errno value reporting on failed mmap
    Date
    From: Nelson Elhage <nelhage@nelhage.com>

    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 | 4 +++-
    1 files changed, 3 insertions(+), 1 deletions(-)

    diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
    index 8b19e7a..963d63d 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,
    evlist->mmap[idx].mask = mask;
    evlist->mmap[idx].base = mmap(NULL, evlist->mmap_len, prot,
    MAP_SHARED, fd, 0);
    - if (evlist->mmap[idx].base == MAP_FAILED)
    + if (evlist->mmap[idx].base == MAP_FAILED) {
    + evlist->mmap[idx].base = NULL;
    return -1;
    + }

    perf_evlist__add_pollfd(evlist, fd);
    return 0;
    --
    1.7.8.rc0.35.gee6df


    \
     
     \ /
      Last update: 2011-12-20 20:21    [W:2.224 / U:0.944 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site