lkml.org 
[lkml]   [2021]   [Jul]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 06/20] perf dso: fix memory leak in dso__new_map
Date
ASan reports a memory leak when running the 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 <rickyman7@gmail.com>
---
tools/perf/util/dso.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index d786cf6b0cfa65f2..ee15db2be2f43403 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -1154,8 +1154,10 @@ struct map *dso__new_map(const char *name)
struct map *map = NULL;
struct dso *dso = dso__new(name);

- if (dso)
+ if (dso) {
map = map__new2(0, dso);
+ dso__put(dso);
+ }

return map;
}
--
2.31.1
\
 
 \ /
  Last update: 2021-07-15 18:09    [W:0.199 / U:2.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site