]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
perf evsel: Fix memory leaks on evsel->counts
authorNamhyung Kim <namhyung.kim@lge.com>
Fri, 25 Jan 2013 01:44:44 +0000 (10:44 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 30 Jan 2013 13:37:04 +0000 (10:37 -0300)
The ->counts field was never freed in the current code.  Add
perf_evsel__free_counts() function to free it properly.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1359078284-32080-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-stat.c
tools/perf/tests/open-syscall-all-cpus.c
tools/perf/util/evsel.c
tools/perf/util/evsel.h

index 493043abd164f6afb894a230606a1d03781f9034..0368a1036ad647dcb7a58de7034dafeefa71f12d 100644 (file)
@@ -1372,6 +1372,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
 out_free_fd:
        list_for_each_entry(pos, &evsel_list->entries, node) {
                perf_evsel__free_stat_priv(pos);
+               perf_evsel__free_counts(pos);
                perf_evsel__free_prev_raw_counts(pos);
        }
        perf_evlist__delete_maps(evsel_list);
index 9b920a0cce79f9b7d55495596933ec8bd0b807fc..b0657a9ccda638febdcd39c40f30cecf06c0ece6 100644 (file)
@@ -98,6 +98,7 @@ int test__open_syscall_event_on_all_cpus(void)
                }
        }
 
+       perf_evsel__free_counts(evsel);
 out_close_fd:
        perf_evsel__close_fd(evsel, 1, threads->nr);
 out_evsel_delete:
index dbdcca43cac670fd73e0dc6b468c1b69086962c2..baa26ddbcc7b56984085a091c45c675dfd7678aa 100644 (file)
@@ -640,6 +640,11 @@ void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads)
                }
 }
 
+void perf_evsel__free_counts(struct perf_evsel *evsel)
+{
+       free(evsel->counts);
+}
+
 void perf_evsel__exit(struct perf_evsel *evsel)
 {
        assert(list_empty(&evsel->node));
index 3a4cd60044ea41606ae8e86d52217758b4f3bb33..cbf42322a27ef10a04387669b60b000a4346d06b 100644 (file)
@@ -117,6 +117,7 @@ int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads);
 int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus);
 void perf_evsel__free_fd(struct perf_evsel *evsel);
 void perf_evsel__free_id(struct perf_evsel *evsel);
+void perf_evsel__free_counts(struct perf_evsel *evsel);
 void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads);
 
 void __perf_evsel__set_sample_bit(struct perf_evsel *evsel,