Commit 581e295a authored by Riccardo Mancini's avatar Riccardo Mancini Committed by Arnaldo Carvalho de Melo

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: default avatarRiccardo Mancini <rickyman7@gmail.com>
Fixes: d3a7c489 ("perf tools: Reference count struct dso")
Cc: Ian Rogers <irogers@google.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>
Link: http://lore.kernel.org/lkml/60bfe0cd06e89e2ca33646eb8468d7f5de2ee597.1626343282.git.rickyman7@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent dccfca92
...@@ -1154,8 +1154,10 @@ struct map *dso__new_map(const char *name) ...@@ -1154,8 +1154,10 @@ struct map *dso__new_map(const char *name)
struct map *map = NULL; struct map *map = NULL;
struct dso *dso = dso__new(name); struct dso *dso = dso__new(name);
if (dso) if (dso) {
map = map__new2(0, dso); map = map__new2(0, dso);
dso__put(dso);
}
return map; return map;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment