[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAP-5=fWdgFCBj0r4nVgEXnwOpckCXOb-FSTqexuDw=YiNnH+9Q@mail.gmail.com>
Date: Sun, 19 Jul 2020 14:41:46 -0700
From: Ian Rogers <irogers@...gle.com>
To: Jiri Olsa <jolsa@...nel.org>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
lkml <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Michael Petlan <mpetlan@...hat.com>,
Andi Kleen <ak@...ux.intel.com>,
Kajol Jain <kjain@...ux.ibm.com>,
John Garry <john.garry@...wei.com>,
"Paul A. Clarke" <pc@...ibm.com>,
Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH 01/19] perf metric: Fix memory leak in expr__add_id function
On Sun, Jul 19, 2020 at 11:13 AM Jiri Olsa <jolsa@...nel.org> wrote:
>
> Arnaldo found that we don't release value data in case the
> hashmap__set fails. Releasing it in case of an error.
>
> Reported-by: Arnaldo Carvalho de Melo <acme@...hat.com>
> Signed-off-by: Jiri Olsa <jolsa@...nel.org>
Acked-by: Ian Rogers <irogers@...gle.com>
> ---
> tools/perf/util/expr.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c
> index 5d05f9765ed8..578a173d4873 100644
> --- a/tools/perf/util/expr.c
> +++ b/tools/perf/util/expr.c
> @@ -47,6 +47,8 @@ int expr__add_id_val(struct expr_parse_ctx *ctx, const char *id, double val)
> }
> ret = hashmap__set(&ctx->ids, id, data_ptr,
> (const void **)&old_key, (void **)&old_data);
> + if (ret)
> + free(data_ptr);
> free(old_key);
> free(old_data);
> return ret;
> --
> 2.25.4
>
Powered by blists - more mailing lists