[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YHglZSAF/iUGloPY@krava>
Date: Thu, 15 Apr 2021 13:37:09 +0200
From: Jiri Olsa <jolsa@...hat.com>
To: Zhen Lei <thunder.leizhen@...wei.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Namhyung Kim <namhyung@...nel.org>,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/1] perf map: Fix error return code in maps__clone()
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@...wei.com>
> Signed-off-by: Zhen Lei <thunder.leizhen@...wei.com>
Acked-by: Jiri Olsa <jolsa@...hat.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
>
>
Powered by blists - more mailing lists