Skip to content

Commit 581e295

Browse files
Manciukicacmel
authored andcommitted
perf dso: Fix memory leak in dso__new_map()
ASan reports a memory leak when running: # perf test "65: maps__merge_in". The causes of the leaks are two, this patch addresses only the first one, which is related to dso__new_map(). The bug is that dso__new_map() creates a new dso but never decreases the refcount it gets from creating it. This patch adds the missing dso__put(). Signed-off-by: Riccardo Mancini <[email protected]> Fixes: d3a7c48 ("perf tools: Reference count struct dso") Cc: Ian Rogers <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lore.kernel.org/lkml/60bfe0cd06e89e2ca33646eb8468d7f5de2ee597.1626343282.git.rickyman7@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent dccfca9 commit 581e295

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tools/perf/util/dso.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,8 +1154,10 @@ struct map *dso__new_map(const char *name)
11541154
struct map *map = NULL;
11551155
struct dso *dso = dso__new(name);
11561156

1157-
if (dso)
1157+
if (dso) {
11581158
map = map__new2(0, dso);
1159+
dso__put(dso);
1160+
}
11591161

11601162
return map;
11611163
}

0 commit comments

Comments
 (0)