Skip to content

Commit 3118d14

Browse files
captain5050namhyung
authored andcommitted
perf c2c: Clean up some defensive gets and make asan clean
To deal with histogram code that had missing gets the c2c code had some defensive gets. Those other issues were cleaned up by the reference count checker, clean them up for the c2c command here. Signed-off-by: Ian Rogers <irogers@google.com> Reviewed-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent 1da7c10 commit 3118d14

1 file changed

Lines changed: 14 additions & 22 deletions

File tree

tools/perf/builtin-c2c.c

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ static int process_sample_event(const struct perf_tool *tool __maybe_unused,
322322
struct c2c_stats stats = { .nr_entries = 0, };
323323
struct hist_entry *he;
324324
struct addr_location al;
325-
struct mem_info *mi, *mi_dup;
325+
struct mem_info *mi = NULL;
326326
struct callchain_cursor *cursor;
327327
int ret;
328328

@@ -349,20 +349,15 @@ static int process_sample_event(const struct perf_tool *tool __maybe_unused,
349349
goto out;
350350
}
351351

352-
/*
353-
* The mi object is released in hists__add_entry_ops,
354-
* if it gets sorted out into existing data, so we need
355-
* to take the copy now.
356-
*/
357-
mi_dup = mem_info__get(mi);
358-
359352
c2c_decode_stats(&stats, mi);
360353

361354
he = hists__add_entry_ops(&c2c_hists->hists, &c2c_entry_ops,
362355
&al, NULL, NULL, mi, NULL,
363356
sample, true);
364-
if (he == NULL)
365-
goto free_mi;
357+
if (he == NULL) {
358+
ret = -ENOMEM;
359+
goto out;
360+
}
366361

367362
c2c_he = container_of(he, struct c2c_hist_entry, he);
368363
c2c_add_stats(&c2c_he->stats, &stats);
@@ -393,17 +388,19 @@ static int process_sample_event(const struct perf_tool *tool __maybe_unused,
393388
int cpu = sample->cpu == (unsigned int) -1 ? 0 : sample->cpu;
394389
int node = c2c.cpu2node[cpu];
395390

396-
mi = mi_dup;
397-
398391
c2c_hists = he__get_c2c_hists(he, c2c.cl_sort, 2, machine->env);
399-
if (!c2c_hists)
400-
goto free_mi;
392+
if (!c2c_hists) {
393+
ret = -ENOMEM;
394+
goto out;
395+
}
401396

402397
he = hists__add_entry_ops(&c2c_hists->hists, &c2c_entry_ops,
403398
&al, NULL, NULL, mi, NULL,
404399
sample, true);
405-
if (he == NULL)
406-
goto free_mi;
400+
if (he == NULL) {
401+
ret = -ENOMEM;
402+
goto out;
403+
}
407404

408405
c2c_he = container_of(he, struct c2c_hist_entry, he);
409406
c2c_add_stats(&c2c_he->stats, &stats);
@@ -421,14 +418,9 @@ static int process_sample_event(const struct perf_tool *tool __maybe_unused,
421418
}
422419

423420
out:
421+
mem_info__put(mi);
424422
addr_location__exit(&al);
425423
return ret;
426-
427-
free_mi:
428-
mem_info__put(mi_dup);
429-
mem_info__put(mi);
430-
ret = -ENOMEM;
431-
goto out;
432424
}
433425

434426
static const char * const c2c_usage[] = {

0 commit comments

Comments
 (0)