summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/hist.c39
1 files 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,
396 * adding new entries. So we need to save a copy. 396 * adding new entries. So we need to save a copy.
397 */ 397 */
398 he->branch_info = malloc(sizeof(*he->branch_info)); 398 he->branch_info = malloc(sizeof(*he->branch_info));
399 if (he->branch_info == NULL) { 399 if (he->branch_info == NULL)
400 map__zput(he->ms.map); 400 goto err;
401 free(he->stat_acc);
402 return -ENOMEM;
403 }
404 401
405 memcpy(he->branch_info, template->branch_info, 402 memcpy(he->branch_info, template->branch_info,
406 sizeof(*he->branch_info)); 403 sizeof(*he->branch_info));
@@ -419,21 +416,8 @@ static int hist_entry__init(struct hist_entry *he,
419 416
420 if (he->raw_data) { 417 if (he->raw_data) {
421 he->raw_data = memdup(he->raw_data, he->raw_size); 418 he->raw_data = memdup(he->raw_data, he->raw_size);
422 419 if (he->raw_data == NULL)
423 if (he->raw_data == NULL) { 420 goto err_infos;
424 map__put(he->ms.map);
425 if (he->branch_info) {
426 map__put(he->branch_info->from.map);
427 map__put(he->branch_info->to.map);
428 free(he->branch_info);
429 }
430 if (he->mem_info) {
431 map__put(he->mem_info->iaddr.map);
432 map__put(he->mem_info->daddr.map);
433 }
434 free(he->stat_acc);
435 return -ENOMEM;
436 }
437 } 421 }
438 INIT_LIST_HEAD(&he->pairs.node); 422 INIT_LIST_HEAD(&he->pairs.node);
439 thread__get(he->thread); 423 thread__get(he->thread);
@@ -444,6 +428,21 @@ static int hist_entry__init(struct hist_entry *he,
444 he->leaf = true; 428 he->leaf = true;
445 429
446 return 0; 430 return 0;
431
432err_infos:
433 if (he->branch_info) {
434 map__put(he->branch_info->from.map);
435 map__put(he->branch_info->to.map);
436 free(he->branch_info);
437 }
438 if (he->mem_info) {
439 map__put(he->mem_info->iaddr.map);
440 map__put(he->mem_info->daddr.map);
441 }
442err:
443 map__zput(he->ms.map);
444 free(he->stat_acc);
445 return -ENOMEM;
447} 446}
448 447
449static void *hist_entry__zalloc(size_t size) 448static void *hist_entry__zalloc(size_t size)