lkml.org 
[lkml]   [2021]   [Jul]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 06/20] perf dso: fix memory leak in dso__new_map
Em Thu, Jul 15, 2021 at 06:07:11PM +0200, Riccardo Mancini escreveu:
> 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.

Thanks, applied.

This needs some extra thinking for some unrelated issue, namely that
this dso isn't linked in the machine dso list, I think this is only used
by 'perf probe' :-\

I guess this won't be a problem since using the machine dso list is
important just for other tools, like when traversing to get the
build-ids, etc.

- Arnaldo

> 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
>

--

- Arnaldo

\
 
 \ /
  Last update: 2021-07-15 22:02    [W:0.618 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site