diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-04-08 10:57:03 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-04-10 09:13:58 -0400 |
commit | d998b732599b304c3865e8e5c7ba6250faba6589 (patch) | |
tree | a4575d1adf2fce2879fece66c2b767f4fc46708d /tools/perf | |
parent | 7764a385f60bd200304a33124bdb4e684caeabdf (diff) |
perf tools: Fix error path to do closedir() when synthesizing threads
When traversing /proc to synthesize the PERF_RECORD_FORK et al events we
were bailing out on errors without calling closedir(), fix it.
Reported-by: David Ahern <dsahern@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-vxtp593rfztgbi8noy0m967p@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/util/event.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 9d0985131252..ff866c4d2e2f 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -387,6 +387,7 @@ static int __event__synthesize_thread(union perf_event *comm_event, | |||
387 | DIR *tasks; | 387 | DIR *tasks; |
388 | struct dirent dirent, *next; | 388 | struct dirent dirent, *next; |
389 | pid_t tgid, ppid; | 389 | pid_t tgid, ppid; |
390 | int rc = 0; | ||
390 | 391 | ||
391 | /* special case: only send one comm event using passed in pid */ | 392 | /* special case: only send one comm event using passed in pid */ |
392 | if (!full) { | 393 | if (!full) { |
@@ -414,38 +415,38 @@ static int __event__synthesize_thread(union perf_event *comm_event, | |||
414 | 415 | ||
415 | while (!readdir_r(tasks, &dirent, &next) && next) { | 416 | while (!readdir_r(tasks, &dirent, &next) && next) { |
416 | char *end; | 417 | char *end; |
417 | int rc = 0; | ||
418 | pid_t _pid; | 418 | pid_t _pid; |
419 | 419 | ||
420 | _pid = strtol(dirent.d_name, &end, 10); | 420 | _pid = strtol(dirent.d_name, &end, 10); |
421 | if (*end) | 421 | if (*end) |
422 | continue; | 422 | continue; |
423 | 423 | ||
424 | rc = -1; | ||
424 | if (perf_event__prepare_comm(comm_event, _pid, machine, | 425 | if (perf_event__prepare_comm(comm_event, _pid, machine, |
425 | &tgid, &ppid) != 0) | 426 | &tgid, &ppid) != 0) |
426 | return -1; | 427 | break; |
427 | 428 | ||
428 | if (perf_event__synthesize_fork(tool, fork_event, _pid, tgid, | 429 | if (perf_event__synthesize_fork(tool, fork_event, _pid, tgid, |
429 | ppid, process, machine) < 0) | 430 | ppid, process, machine) < 0) |
430 | return -1; | 431 | break; |
431 | /* | 432 | /* |
432 | * Send the prepared comm event | 433 | * Send the prepared comm event |
433 | */ | 434 | */ |
434 | if (process(tool, comm_event, &synth_sample, machine) != 0) | 435 | if (process(tool, comm_event, &synth_sample, machine) != 0) |
435 | return -1; | 436 | break; |
436 | 437 | ||
438 | rc = 0; | ||
437 | if (_pid == pid) { | 439 | if (_pid == pid) { |
438 | /* process the parent's maps too */ | 440 | /* process the parent's maps too */ |
439 | rc = perf_event__synthesize_mmap_events(tool, mmap_event, pid, tgid, | 441 | rc = perf_event__synthesize_mmap_events(tool, mmap_event, pid, tgid, |
440 | process, machine, mmap_data); | 442 | process, machine, mmap_data); |
443 | if (rc) | ||
444 | break; | ||
441 | } | 445 | } |
442 | |||
443 | if (rc) | ||
444 | return rc; | ||
445 | } | 446 | } |
446 | 447 | ||
447 | closedir(tasks); | 448 | closedir(tasks); |
448 | return 0; | 449 | return rc; |
449 | } | 450 | } |
450 | 451 | ||
451 | int perf_event__synthesize_thread_map(struct perf_tool *tool, | 452 | int perf_event__synthesize_thread_map(struct perf_tool *tool, |