linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Wang Nan <wangnan0@huawei.com>,
	Alexei Starovoitov <ast@kernel.org>,
	He Kuang <hekuang@huawei.com>, Jiri Olsa <jolsa@kernel.org>,
	Li Zefan <lizefan@huawei.com>,
	Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
	Namhyung Kim <namhyung@kernel.org>,
	pi3orama@163.com, Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 11/11] perf record: Ensure return non-zero rc when mmap fail
Date: Mon, 29 Feb 2016 16:22:07 -0300	[thread overview]
Message-ID: <1456773727-3005-12-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1456773727-3005-1-git-send-email-acme@kernel.org>

From: Wang Nan <wangnan0@huawei.com>

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 <wangnan0@huawei.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1456479154-136027-30-git-send-email-wangnan0@huawei.com
Signed-off-by: He Kuang <hekuang@huawei.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-record.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

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;
 	}
-- 
2.5.0

  parent reply	other threads:[~2016-02-29 19:22 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-29 19:21 [GIT PULL 00/11] perf/core improvements and fixes Arnaldo Carvalho de Melo
2016-02-29 19:21 ` [PATCH 01/11] perf tools: Fix python extension build Arnaldo Carvalho de Melo
2016-02-29 19:21 ` [PATCH 02/11] perf trace: Check and discard not only 'nr' but also '__syscall_nr' Arnaldo Carvalho de Melo
2016-02-29 19:21 ` [PATCH 03/11] tracing/syscalls: Rename "/format" tracepoint field name "nr" to "__syscall_nr: Arnaldo Carvalho de Melo
2016-02-29 19:22 ` [PATCH 04/11] tools lib traceevent: Split pevent_print_event() into specific functionality functions Arnaldo Carvalho de Melo
2016-02-29 19:22 ` [PATCH 05/11] perf stat: Check existence of frontend/backed stalled cycles Arnaldo Carvalho de Melo
2016-03-03  8:28   ` Ingo Molnar
2016-03-03 12:49     ` Arnaldo Carvalho de Melo
2016-03-03 12:50       ` Arnaldo Carvalho de Melo
2016-02-29 19:22 ` [PATCH 06/11] perf data: Support converting data from bpf_perf_event_output() Arnaldo Carvalho de Melo
2016-02-29 19:22 ` [PATCH 07/11] perf data: Explicitly set byte order for integer types Arnaldo Carvalho de Melo
2016-02-29 19:22 ` [PATCH 08/11] perf record: Use WARN_ONCE to replace 'if' condition Arnaldo Carvalho de Melo
2016-02-29 19:22 ` [PATCH 09/11] perf record: Extract synthesize code to record__synthesize() Arnaldo Carvalho de Melo
2016-02-29 19:22 ` [PATCH 10/11] perf record: Introduce record__finish_output() to finish a perf.data Arnaldo Carvalho de Melo
2016-02-29 19:22 ` Arnaldo Carvalho de Melo [this message]
2016-03-03  8:21 ` [GIT PULL 00/11] perf/core improvements and fixes Ingo Molnar
2016-03-03  9:15   ` Jiri Olsa
2016-03-03  9:53     ` [PATCH] perf tools: Fix locale handling in pmu parsing Jiri Olsa
2016-03-03 16:20       ` Andi Kleen
2016-03-05  8:14       ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-03-08 13:23         ` Ingo Molnar
2016-03-08 18:42           ` [PATCH][perf/core] perf tools: Omit unnecessary cast in perf_pmu__parse_scale Jiri Olsa
2016-03-09 13:43             ` Arnaldo Carvalho de Melo
2016-03-11  8:46             ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-03-03 14:38   ` [GIT PULL 00/11] perf/core improvements and fixes Arnaldo Carvalho de Melo
2016-03-05  8:08     ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1456773727-3005-12-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=ast@kernel.org \
    --cc=hekuang@huawei.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=pi3orama@163.com \
    --cc=wangnan0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).