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

perf machine: Fix __machine__findnew_thread() error path

When thread__init_map_groups() fails, a new thread should be removed
from the rbtree since it's gonna be freed. Also update last match cache
only if the function succeeded.

Reported-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1420763892-15535-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
260d819e c6e5e9fb

+3 -1
+3 -1
tools/perf/util/machine.c
··· 389 389 if (th != NULL) { 390 390 rb_link_node(&th->rb_node, parent, p); 391 391 rb_insert_color(&th->rb_node, &machine->threads); 392 - machine->last_match = th; 393 392 394 393 /* 395 394 * We have to initialize map_groups separately ··· 399 400 * leader and that would screwed the rb tree. 400 401 */ 401 402 if (thread__init_map_groups(th, machine)) { 403 + rb_erase(&th->rb_node, &machine->threads); 402 404 thread__delete(th); 403 405 return NULL; 404 406 } 407 + 408 + machine->last_match = th; 405 409 } 406 410 407 411 return th;