[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-c57589106fd6d996dbf3757708baa4a3fb91850f@git.kernel.org>
Date: Sat, 9 Mar 2019 12:06:21 -0800
From: tip-bot for Jiri Olsa <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: namhyung@...nel.org, ravi.bangoria@...ux.ibm.com,
peterz@...radead.org, hpa@...or.com, linux-kernel@...r.kernel.org,
alexander.shishkin@...ux.intel.com,
jonas.rabenstein@...dium.uni-erlangen.de, ak@...ux.intel.com,
tglx@...utronix.de, mingo@...nel.org, acme@...hat.com,
nasastry@...ibm.com, jolsa@...nel.org
Subject: [tip:perf/urgent] perf hist: Add error path into hist_entry__init
Commit-ID: c57589106fd6d996dbf3757708baa4a3fb91850f
Gitweb: https://git.kernel.org/tip/c57589106fd6d996dbf3757708baa4a3fb91850f
Author: Jiri Olsa <jolsa@...nel.org>
AuthorDate: Tue, 5 Mar 2019 16:25:30 +0100
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Wed, 6 Mar 2019 18:16:30 -0300
perf hist: Add error path into hist_entry__init
Adding error path into hist_entry__init to unify error handling, so
every new member does not need to free everything else.
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Andi Kleen <ak@...ux.intel.com>
Cc: Jonas Rabenstein <jonas.rabenstein@...dium.uni-erlangen.de>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Ravi Bangoria <ravi.bangoria@...ux.ibm.com>
Cc: nageswara r sastry <nasastry@...ibm.com>
Link: http://lkml.kernel.org/r/20190305152536.21035-3-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/util/hist.c | 39 +++++++++++++++++++--------------------
1 file changed, 19 insertions(+), 20 deletions(-)
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 669f961316f0..74e307d17c49 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -396,11 +396,8 @@ static int hist_entry__init(struct hist_entry *he,
* adding new entries. So we need to save a copy.
*/
he->branch_info = malloc(sizeof(*he->branch_info));
- if (he->branch_info == NULL) {
- map__zput(he->ms.map);
- free(he->stat_acc);
- return -ENOMEM;
- }
+ if (he->branch_info == NULL)
+ goto err;
memcpy(he->branch_info, template->branch_info,
sizeof(*he->branch_info));
@@ -419,21 +416,8 @@ static int hist_entry__init(struct hist_entry *he,
if (he->raw_data) {
he->raw_data = memdup(he->raw_data, he->raw_size);
-
- if (he->raw_data == NULL) {
- map__put(he->ms.map);
- if (he->branch_info) {
- map__put(he->branch_info->from.map);
- map__put(he->branch_info->to.map);
- free(he->branch_info);
- }
- if (he->mem_info) {
- map__put(he->mem_info->iaddr.map);
- map__put(he->mem_info->daddr.map);
- }
- free(he->stat_acc);
- return -ENOMEM;
- }
+ if (he->raw_data == NULL)
+ goto err_infos;
}
INIT_LIST_HEAD(&he->pairs.node);
thread__get(he->thread);
@@ -444,6 +428,21 @@ static int hist_entry__init(struct hist_entry *he,
he->leaf = true;
return 0;
+
+err_infos:
+ if (he->branch_info) {
+ map__put(he->branch_info->from.map);
+ map__put(he->branch_info->to.map);
+ free(he->branch_info);
+ }
+ if (he->mem_info) {
+ map__put(he->mem_info->iaddr.map);
+ map__put(he->mem_info->daddr.map);
+ }
+err:
+ map__zput(he->ms.map);
+ free(he->stat_acc);
+ return -ENOMEM;
}
static void *hist_entry__zalloc(size_t size)
Powered by blists - more mailing lists