Commit c5758910 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo
Browse files

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: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jonas Rabenstein <jonas.rabenstein@studium.uni-erlangen.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Cc: nageswara r sastry <nasastry@in.ibm.com>
Link: http://lkml.kernel.org/r/20190305152536.21035-3-jolsa@kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent e34c9402
Loading
Loading
Loading
Loading
+19 −20
Original line number Diff line number Diff line
@@ -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,9 +416,20 @@ 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)
			goto err_infos;
	}
	INIT_LIST_HEAD(&he->pairs.node);
	thread__get(he->thread);
	he->hroot_in  = RB_ROOT_CACHED;
	he->hroot_out = RB_ROOT_CACHED;

		if (he->raw_data == NULL) {
			map__put(he->ms.map);
	if (!symbol_conf.report_hierarchy)
		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);
@@ -431,20 +439,11 @@ static int hist_entry__init(struct hist_entry *he,
		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;
}
	}
	INIT_LIST_HEAD(&he->pairs.node);
	thread__get(he->thread);
	he->hroot_in  = RB_ROOT_CACHED;
	he->hroot_out = RB_ROOT_CACHED;

	if (!symbol_conf.report_hierarchy)
		he->leaf = true;

	return 0;
}

static void *hist_entry__zalloc(size_t size)
{