Commit 260d819e3abdbdaa2b88fb983d1314f1b263f9e2
Committed by
Arnaldo Carvalho de Melo
1 parent
c6e5e9fbc3
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
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>
Showing 1 changed file with 3 additions and 1 deletions Side-by-side Diff
tools/perf/util/machine.c
... | ... | @@ -389,7 +389,6 @@ |
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 |
396 | 395 | |
... | ... | @@ -400,9 +399,12 @@ |
400 | 399 | * leader and that would screwed the rb tree. |
401 | 400 | */ |
402 | 401 | if (thread__init_map_groups(th, machine)) { |
402 | + rb_erase(&th->rb_node, &machine->threads); | |
403 | 403 | thread__delete(th); |
404 | 404 | return NULL; |
405 | 405 | } |
406 | + | |
407 | + machine->last_match = th; | |
406 | 408 | } |
407 | 409 | |
408 | 410 | return th; |