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 <[email protected]> Signed-off-by: Zhen Lei <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: zhen lei <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 671b60c commit c6f8714

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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)