Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Ian Rogers and committed by
Namhyung Kim
3118d143 1da7c10b

+14 -22
+14 -22
tools/perf/builtin-c2c.c
··· 322 322 struct c2c_stats stats = { .nr_entries = 0, }; 323 323 struct hist_entry *he; 324 324 struct addr_location al; 325 - struct mem_info *mi, *mi_dup; 325 + struct mem_info *mi = NULL; 326 326 struct callchain_cursor *cursor; 327 327 int ret; 328 328 ··· 349 349 goto out; 350 350 } 351 351 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 - 359 352 c2c_decode_stats(&stats, mi); 360 353 361 354 he = hists__add_entry_ops(&c2c_hists->hists, &c2c_entry_ops, 362 355 &al, NULL, NULL, mi, NULL, 363 356 sample, true); 364 - if (he == NULL) 365 - goto free_mi; 357 + if (he == NULL) { 358 + ret = -ENOMEM; 359 + goto out; 360 + } 366 361 367 362 c2c_he = container_of(he, struct c2c_hist_entry, he); 368 363 c2c_add_stats(&c2c_he->stats, &stats); ··· 388 393 int cpu = sample->cpu == (unsigned int) -1 ? 0 : sample->cpu; 389 394 int node = c2c.cpu2node[cpu]; 390 395 391 - mi = mi_dup; 392 - 393 396 c2c_hists = he__get_c2c_hists(he, c2c.cl_sort, 2, machine->env); 394 - if (!c2c_hists) 395 - goto free_mi; 397 + if (!c2c_hists) { 398 + ret = -ENOMEM; 399 + goto out; 400 + } 396 401 397 402 he = hists__add_entry_ops(&c2c_hists->hists, &c2c_entry_ops, 398 403 &al, NULL, NULL, mi, NULL, 399 404 sample, true); 400 - if (he == NULL) 401 - goto free_mi; 405 + if (he == NULL) { 406 + ret = -ENOMEM; 407 + goto out; 408 + } 402 409 403 410 c2c_he = container_of(he, struct c2c_hist_entry, he); 404 411 c2c_add_stats(&c2c_he->stats, &stats); ··· 418 421 } 419 422 420 423 out: 424 + mem_info__put(mi); 421 425 addr_location__exit(&al); 422 426 return ret; 423 - 424 - free_mi: 425 - mem_info__put(mi_dup); 426 - mem_info__put(mi); 427 - ret = -ENOMEM; 428 - goto out; 429 427 } 430 428 431 429 static const char * const c2c_usage[] = {