[RFC PATCH 23/25] perf stat: Fix a return error issue in hardware-grouping

weilin.wang
2023-09-25T06:21:18Z

Update the hw_aware_parse_ids() goto to improve error handling.

Signed-off-by: Weilin Wang <weilin.wang@intel.com>
---
tools/perf/util/metricgroup.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 07a82fa21..6a4404226 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -2196,11 +2196,11 @@ static int hw_aware_parse_ids(struct perf_pmu *fake_pmu,
*out_evlist = NULL;
ret = hw_aware_build_grouping(ids, &grouping);
if (ret)
- goto err_out;
+ goto out;
ret = hw_aware_metricgroup__build_event_string(&grouping_str, modifier,
tool_events, &grouping);
if (ret)
- goto err_out;
+ goto out;

parsed_evlist = evlist__new();
if (!parsed_evlist) {
@@ -2225,10 +2225,11 @@ static int hw_aware_parse_ids(struct perf_pmu *fake_pmu,
*out_evlist = parsed_evlist;
parsed_evlist = NULL;
err_out:
- metricgroup__free_group_list(&grouping);
- metricgroup__free_grouping_strs(&grouping_str);
parse_events_error__exit(&parse_error);
evlist__delete(parsed_evlist);
+out:
+ metricgroup__free_group_list(&grouping);
+ metricgroup__free_grouping_strs(&grouping_str);
return ret;
}

--
2.39.3