From: Jiri Olsa <jolsa@redhat.com>
To: Zhen Lei <thunder.leizhen@huawei.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Namhyung Kim <namhyung@kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] perf map: Fix error return code in maps__clone()
Date: Thu, 15 Apr 2021 13:37:09 +0200 [thread overview]
Message-ID: <YHglZSAF/iUGloPY@krava> (raw)
In-Reply-To: <20210415092744.3793-1-thunder.leizhen@huawei.com>
On Thu, Apr 15, 2021 at 05:27:44PM +0800, Zhen Lei wrote:
> Although 'err' has been initialized to -ENOMEM, but it will be reassigned
> by the "err = unwind__prepare_access(...)" statement in the for loop. So
> that, the value of 'err' is unknown when map__clone() failed.
>
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
thanks,
jirka
> ---
> tools/perf/util/map.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
> index fbc40a2c17d4dca..8af693d9678cefe 100644
> --- a/tools/perf/util/map.c
> +++ b/tools/perf/util/map.c
> @@ -840,15 +840,18 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp)
> int maps__clone(struct thread *thread, struct maps *parent)
> {
> struct maps *maps = thread->maps;
> - int err = -ENOMEM;
> + int err;
> struct map *map;
>
> down_read(&parent->lock);
>
> maps__for_each_entry(parent, map) {
> struct map *new = map__clone(map);
> - if (new == NULL)
> +
> + if (new == NULL) {
> + err = -ENOMEM;
> goto out_unlock;
> + }
>
> err = unwind__prepare_access(maps, new, NULL);
> if (err)
> --
> 2.26.0.106.g9fadedd
>
>
next prev parent reply other threads:[~2021-04-15 11:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-15 9:27 [PATCH 1/1] perf map: Fix error return code in maps__clone() Zhen Lei
2021-04-15 11:37 ` Jiri Olsa [this message]
2021-04-15 12:42 ` Arnaldo Carvalho de Melo
2021-04-15 14:20 ` Leizhen (ThunderTown)
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=YHglZSAF/iUGloPY@krava \
--to=jolsa@redhat.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=thunder.leizhen@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.