[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200521133218.30150-2-liwei391@huawei.com>
Date: Thu, 21 May 2020 21:32:15 +0800
From: Wei Li <liwei391@...wei.com>
To: Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
"Arnaldo Carvalho de Melo" <acme@...nel.org>,
Jiri Olsa <jolsa@...hat.com>,
Mark Rutland <mark.rutland@....com>,
Namhyung Kim <namhyung@...nel.org>
CC: <linux-kernel@...r.kernel.org>, Li Bin <huawei.libin@...wei.com>,
"Xie XiuQi" <xiexiuqi@...wei.com>,
Hongbo Yao <yaohongbo@...wei.com>
Subject: [PATCH 1/4] perf metrictroup: Fix memory leak of metric_events
From: Hongbo Yao <yaohongbo@...wei.com>
Fix memory leak of metric_events in function metricgroup__setup_events()
Signed-off-by: Hongbo Yao <yaohongbo@...wei.com>
---
tools/perf/util/metricgroup.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 926449a7cdbf..69bf0f4d646e 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -184,6 +184,7 @@ static int metricgroup__setup_events(struct list_head *groups,
if (!evsel) {
pr_debug("Cannot resolve %s: %s\n",
eg->metric_name, eg->metric_expr);
+ free(metric_events);
continue;
}
for (i = 0; i < eg->idnum; i++)
@@ -191,11 +192,13 @@ static int metricgroup__setup_events(struct list_head *groups,
me = metricgroup__lookup(metric_events_list, evsel, true);
if (!me) {
ret = -ENOMEM;
+ free(metric_events);
break;
}
expr = malloc(sizeof(struct metric_expr));
if (!expr) {
ret = -ENOMEM;
+ free(metric_events);
break;
}
expr->metric_expr = eg->metric_expr;
--
2.17.1
Powered by blists - more mailing lists