Commit f58385f6 authored by Kan Liang's avatar Kan Liang Committed by Arnaldo Carvalho de Melo

perf mmap: Fix accessing unmapped mmap in perf_mmap__read_done()

There is a segmentation fault when running 'perf trace'. For example:

  [root@jouet e]# perf trace -e *chdir -o /tmp/bla perf report --ignore-vmlinux -i ../

The perf_mmap__consume() could unmap the mmap. It needs to check the
refcnt in perf_mmap__read_done().
Reported-by: default avatarArnaldo Carvalho de Melo <>
Signed-off-by: default avatarKan Liang <>
Cc: Jiri Olsa <>
Cc: Namhyung Kim <>
Cc: Wang Nan <>
Fixes: ee023de0 ("perf mmap: Introduce perf_mmap__read_done()")
Link: default avatarArnaldo Carvalho de Melo <>
parent b4c786e5
......@@ -317,5 +317,11 @@ int perf_mmap__push(struct perf_mmap *md, void *to,
void perf_mmap__read_done(struct perf_mmap *map)
* Check if event was unmapped due to a POLLHUP/POLLERR.
if (!refcount_read(&map->refcnt))
map->prev = perf_mmap__read_head(map);
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment