Skip to content

Commit c6f8714

Browse files
Zhen Leiacmel
authored andcommitted
perf map: Fix error return code in maps__clone()
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: 6c50258 ("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>
1 parent 671b60c commit c6f8714

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

tools/perf/util/map.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,15 +840,18 @@ int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp)
840840
int maps__clone(struct thread *thread, struct maps *parent)
841841
{
842842
struct maps *maps = thread->maps;
843-
int err = -ENOMEM;
843+
int err;
844844
struct map *map;
845845

846846
down_read(&parent->lock);
847847

848848
maps__for_each_entry(parent, map) {
849849
struct map *new = map__clone(map);
850-
if (new == NULL)
850+
851+
if (new == NULL) {
852+
err = -ENOMEM;
851853
goto out_unlock;
854+
}
852855

853856
err = unwind__prepare_access(maps, new, NULL);
854857
if (err)

0 commit comments

Comments
 (0)