[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tip-946ae1d41d4b0c77b9f63b4a0393d8a1283a7f9d@git.kernel.org>
Date: Wed, 8 Jun 2016 01:37:09 -0700
From: tip-bot for Wang Nan <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: mhiramat@...nel.org, hpa@...or.com, acme@...hat.com,
hekuang@...wei.com, linux-kernel@...r.kernel.org,
namhyung@...nel.org, wangnan0@...wei.com, tglx@...utronix.de,
mingo@...nel.org, lizefan@...wei.com, jolsa@...nel.org
Subject: [tip:perf/core] perf evlist: Fix alloc_mmap() failure path
Commit-ID: 946ae1d41d4b0c77b9f63b4a0393d8a1283a7f9d
Gitweb: http://git.kernel.org/tip/946ae1d41d4b0c77b9f63b4a0393d8a1283a7f9d
Author: Wang Nan <wangnan0@...wei.com>
AuthorDate: Tue, 31 May 2016 13:06:15 +0000
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Fri, 3 Jun 2016 14:53:46 -0300
perf evlist: Fix alloc_mmap() failure path
If zalloc fail, setting evlist->mmap[i].fd is unsafe and
perf_evlist__alloc_mmap() should bail out right after that.
Signed-off-by: Wang Nan <wangnan0@...wei.com>
Acked-by: Masami Hiramatsu <mhiramat@...nel.org>
Cc: He Kuang <hekuang@...wei.com>
Cc: Jiri Olsa <jolsa@...nel.org>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Zefan Li <lizefan@...wei.com>
Cc: pi3orama@....com
Fixes: d4c6fb36ac2c ("perf evsel: Record fd into perf_mmap")
Link: http://lkml.kernel.org/r/1464699975-230440-1-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/util/evlist.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index e0f3094..1b918aa 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -946,9 +946,12 @@ static int perf_evlist__alloc_mmap(struct perf_evlist *evlist)
if (cpu_map__empty(evlist->cpus))
evlist->nr_mmaps = thread_map__nr(evlist->threads);
evlist->mmap = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap));
+ if (!evlist->mmap)
+ return -ENOMEM;
+
for (i = 0; i < evlist->nr_mmaps; i++)
evlist->mmap[i].fd = -1;
- return evlist->mmap != NULL ? 0 : -ENOMEM;
+ return 0;
}
struct mmap_params {
Powered by blists - more mailing lists