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 <a...@redhat.com>
Signed-off-by: Jiri Olsa <jo...@kernel.org>
Acked-by: Ian Rogers <irog...@google.com>
Cc: Alexander Shishkin <alexander.shish...@linux.intel.com>
Cc: Andi Kleen <a...@linux.intel.com>
Cc: John Garry <john.ga...@huawei.com>
Cc: Kajol Jain <kj...@linux.ibm.com>
Cc: Michael Petlan <mpet...@redhat.com>
Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Paul Clarke <p...@us.ibm.com>
Cc: Peter Zijlstra <pet...@infradead.org>
Cc: Stephane Eranian <eran...@google.com>
Link: http://lore.kernel.org/lkml/20200719181320.785305-2-jo...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.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

Reply via email to