diff options
| author | Zhen Lei <thunder.leizhen@huawei.com> | 2021-04-15 17:27:44 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-04-28 13:41:49 +0200 |
| commit | 48189362d36a1eea371e295cad845a69c4def65e (patch) | |
| tree | 1c906e4e2a188977cff2e1be9daaf79101fbfcd0 | |
| parent | 508a1c43118e0f7d0268233a186d2e3112f290b5 (diff) | |
| download | linux-48189362d36a1eea371e295cad845a69c4def65e.tar.gz linux-48189362d36a1eea371e295cad845a69c4def65e.tar.bz2 linux-48189362d36a1eea371e295cad845a69c4def65e.zip | |
perf map: Fix error return code in maps__clone()
[ Upstream commit c6f87141254d16e281e4b4431af7316895207b8f ]
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.
Fixes: 6c502584438bda63 ("perf unwind: Call unwind__prepare_access for forked thread")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: zhen lei <thunder.leizhen@huawei.com>
Link: http://lore.kernel.org/lkml/20210415092744.3793-1-thunder.leizhen@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
| -rw-r--r-- | tools/perf/util/map.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index e2537d5acab0..f4d44f75ba15 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -836,15 +836,18 @@ out: 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) |
