54 lines
1.9 KiB
Diff
54 lines
1.9 KiB
Diff
From f27677eedf71764e9b1d204bf419b2ed538269b0 Mon Sep 17 00:00:00 2001
|
|
From: Jiri Olsa <jolsa@kernel.org>
|
|
Date: Sun, 19 Jul 2020 20:13:02 +0200
|
|
Subject: [PATCH 107/201] perf metric: Fix memory leak in expr__add_id function
|
|
|
|
mainline inclusion
|
|
from mainline-v5.9-rc1
|
|
commit 2c46f54249c6e86d8d81b5ea2452319f197caf17
|
|
category: feature
|
|
bugzilla: https://gitee.com/openeuler/kernel/issues/I8C0CX
|
|
|
|
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2c46f54249c6e86d8d81b5ea2452319f197caf17
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
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@redhat.com>
|
|
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
|
|
Acked-by: Ian Rogers <irogers@google.com>
|
|
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
|
|
Cc: Andi Kleen <ak@linux.intel.com>
|
|
Cc: John Garry <john.garry@huawei.com>
|
|
Cc: Kajol Jain <kjain@linux.ibm.com>
|
|
Cc: Michael Petlan <mpetlan@redhat.com>
|
|
Cc: Namhyung Kim <namhyung@kernel.org>
|
|
Cc: Paul Clarke <pc@us.ibm.com>
|
|
Cc: Peter Zijlstra <peterz@infradead.org>
|
|
Cc: Stephane Eranian <eranian@google.com>
|
|
Link: http://lore.kernel.org/lkml/20200719181320.785305-2-jolsa@kernel.org
|
|
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
|
|
Signed-off-by: hongrongxuan <hongrongxuan@huawei.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 e328931dcfe1..4dec1add3a13 100644
|
|
--- a/tools/perf/util/expr.c
|
|
+++ b/tools/perf/util/expr.c
|
|
@@ -44,6 +44,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.27.0
|
|
|