path: root/tools
diff options
authorWang Nan <>2016-02-26 09:32:17 +0000
committerArnaldo Carvalho de Melo <>2016-03-03 11:10:36 -0300
commit95c365617aa37878592f2f1c6c64e1abb19f0d4a (patch)
tree6217b75ff3a02ef9e4f0ca1020efb096ec331e24 /tools
parente1ab48ba63ee6b2494a67bb60bf99692ecdaca7c (diff)
perf record: Ensure return non-zero rc when mmap fail
perf_evlist__mmap_ex() can fail without setting errno (for example, fail in condition checking. In this case all syscall is success). If this happen, record__open() incorrectly returns 0. Force setting rc is a quick way to avoid this problem, or we have to follow all possible code path in perf_evlist__mmap_ex() to make sure there's at least one system call before returning an error. Signed-off-by: Wang Nan <> Cc: Alexei Starovoitov <> Cc: He Kuang <> Cc: Jiri Olsa <> Cc: Li Zefan <> Cc: Masami Hiramatsu <> Cc: Namhyung Kim <> Cc: Zefan Li <> Cc: Link: Signed-off-by: He Kuang <> Signed-off-by: Arnaldo Carvalho de Melo <>
Diffstat (limited to 'tools')
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 46e2772f838e..515510ecc76a 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -324,7 +324,10 @@ try_again:
} else {
pr_err("failed to mmap with %d (%s)\n", errno,
strerror_r(errno, msg, sizeof(msg)));
- rc = -errno;
+ if (errno)
+ rc = -errno;
+ else
+ rc = -EINVAL;
goto out;