From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>,
pi3orama@163.com, linux-kernel@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@redhat.com>,
He Kuang <hekuang@huawei.com>, Jiri Olsa <jolsa@kernel.org>,
Namhyung Kim <namhyung@kernel.org>, Zefan Li <lizefan@huawei.com>
Subject: Re: [PATCH] perf tools: Fix perf_evlist__alloc_mmap() failure path
Date: Wed, 1 Jun 2016 09:43:12 -0300 [thread overview]
Message-ID: <20160601124312.GN2563@kernel.org> (raw)
In-Reply-To: <20160531222743.90eea3df64157f6ed3c097ef@kernel.org>
Em Tue, May 31, 2016 at 10:27:43PM +0900, Masami Hiramatsu escreveu:
> On Tue, 31 May 2016 13:06:15 +0000
> Wang Nan <wangnan0@huawei.com> wrote:
>
> > If zalloc fail, setting evlist->mmap[i].fd is unsafe.
> > perf_evlist__alloc_mmap() should fail right after zalloc() fail.
>
> Good catch!!
>
> Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Applied, after adding a:
Fixes: d4c6fb36ac2c ("perf evsel: Record fd into perf_mmap")
> Thanks!
>
> >
> > Signed-off-by: Wang Nan <wangnan0@huawei.com>
> > Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> > Cc: He Kuang <hekuang@huawei.com>
> > Cc: Jiri Olsa <jolsa@kernel.org>
> > Cc: Masami Hiramatsu <mhiramat@kernel.org>
> > Cc: Namhyung Kim <namhyung@kernel.org>
> > Cc: Zefan Li <lizefan@huawei.com>
> > Cc: pi3orama@163.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 {
> > --
> > 1.8.3.4
> >
>
>
> --
> Masami Hiramatsu <mhiramat@kernel.org>
next prev parent reply other threads:[~2016-06-01 12:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-31 13:06 [PATCH] perf tools: Fix perf_evlist__alloc_mmap() failure path Wang Nan
2016-05-31 13:27 ` Masami Hiramatsu
2016-06-01 12:43 ` Arnaldo Carvalho de Melo [this message]
2016-06-08 8:37 ` [tip:perf/core] perf evlist: Fix alloc_mmap() " tip-bot for Wang Nan
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=20160601124312.GN2563@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=hekuang@huawei.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=mhiramat@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).