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

Configure Feed

Select the types of activity you want to include in your feed.

perf record: Fix a potential error handling issue

The evlist is allocated at the beginning of cmd_record(). Also free-ing
thread masks should be paired with record__init_thread_masks() which is
called right before __cmd_record().

Let's change the order of these functions to release the resources
correctly in case of errors. This is maybe fine as the process exits,
but it might be a problem if it manages some system-wide resources that
live longer than the process.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: KP Singh <kpsingh@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <song@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20240703223035.2024586-7-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
73bf63a4 1ec6fd34

+3 -3
+3 -3
tools/perf/builtin-record.c
··· 4242 4242 4243 4243 err = __cmd_record(&record, argc, argv); 4244 4244 out: 4245 - evlist__delete(rec->evlist); 4245 + record__free_thread_masks(rec, rec->nr_threads); 4246 + rec->nr_threads = 0; 4246 4247 symbol__exit(); 4247 4248 auxtrace_record__free(rec->itr); 4248 4249 out_opts: 4249 - record__free_thread_masks(rec, rec->nr_threads); 4250 - rec->nr_threads = 0; 4251 4250 evlist__close_control(rec->opts.ctl_fd, rec->opts.ctl_fd_ack, &rec->opts.ctl_fd_close); 4251 + evlist__delete(rec->evlist); 4252 4252 return err; 4253 4253 } 4254 4254