Commit a159e2fe authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf metricgroup: Free metric_events on error

Avoid a simple memory leak.
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Andrii Nakryiko <andriin@fb.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Kim Phillips <kim.phillips@amd.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Martin KaFai Lau <kafai@fb.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <songliubraving@fb.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: Yonghong Song <yhs@fb.com>
Cc: bpf@vger.kernel.org
Cc: kp singh <kpsingh@chromium.org>
Cc: netdev@vger.kernel.org
Link: http://lore.kernel.org/lkml/20200508053629.210324-10-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent fa99ce82
...@@ -177,6 +177,7 @@ static int metricgroup__setup_events(struct list_head *groups, ...@@ -177,6 +177,7 @@ static int metricgroup__setup_events(struct list_head *groups,
if (!evsel) { if (!evsel) {
pr_debug("Cannot resolve %s: %s\n", pr_debug("Cannot resolve %s: %s\n",
eg->metric_name, eg->metric_expr); eg->metric_name, eg->metric_expr);
free(metric_events);
continue; continue;
} }
for (i = 0; metric_events[i]; i++) for (i = 0; metric_events[i]; i++)
...@@ -184,11 +185,13 @@ static int metricgroup__setup_events(struct list_head *groups, ...@@ -184,11 +185,13 @@ static int metricgroup__setup_events(struct list_head *groups,
me = metricgroup__lookup(metric_events_list, evsel, true); me = metricgroup__lookup(metric_events_list, evsel, true);
if (!me) { if (!me) {
ret = -ENOMEM; ret = -ENOMEM;
free(metric_events);
break; break;
} }
expr = malloc(sizeof(struct metric_expr)); expr = malloc(sizeof(struct metric_expr));
if (!expr) { if (!expr) {
ret = -ENOMEM; ret = -ENOMEM;
free(metric_events);
break; break;
} }
expr->metric_expr = eg->metric_expr; expr->metric_expr = eg->metric_expr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment