diff options
author | Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> | 2014-01-16 04:39:47 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-01-16 14:29:02 -0500 |
commit | e53b00d382f4d8f55bcae301f49863c469fdff65 (patch) | |
tree | 7dab9ad69098d2c33aba7f065fc6f540e4fa7b1c /tools/perf/util | |
parent | 981d05adf2e2acc328abb929a6ed3536c0d41c5f (diff) |
perf probe: Release all dynamically allocated parameters
To fix a memory leak, release all dynamically allocated
options/parameters in params data structure. This also
introduces/exports some init/clear routines.
Reported-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: "David A. Long" <dave.long@linaro.org>
Cc: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: yrl.pp-manager.tt@hitachi.com
Link: http://lkml.kernel.org/r/20140116093947.24403.80118.stgit@kbuild-fedora.novalocal
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/probe-event.c | 22 | ||||
-rw-r--r-- | tools/perf/util/probe-event.h | 6 |
2 files changed, 28 insertions, 0 deletions
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 579b655c0f93..c68711c50f47 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c | |||
@@ -794,6 +794,28 @@ int show_available_vars(struct perf_probe_event *pevs __maybe_unused, | |||
794 | } | 794 | } |
795 | #endif | 795 | #endif |
796 | 796 | ||
797 | void line_range__clear(struct line_range *lr) | ||
798 | { | ||
799 | struct line_node *ln; | ||
800 | |||
801 | free(lr->function); | ||
802 | free(lr->file); | ||
803 | free(lr->path); | ||
804 | free(lr->comp_dir); | ||
805 | while (!list_empty(&lr->line_list)) { | ||
806 | ln = list_first_entry(&lr->line_list, struct line_node, list); | ||
807 | list_del(&ln->list); | ||
808 | free(ln); | ||
809 | } | ||
810 | memset(lr, 0, sizeof(*lr)); | ||
811 | } | ||
812 | |||
813 | void line_range__init(struct line_range *lr) | ||
814 | { | ||
815 | memset(lr, 0, sizeof(*lr)); | ||
816 | INIT_LIST_HEAD(&lr->line_list); | ||
817 | } | ||
818 | |||
797 | static int parse_line_num(char **ptr, int *val, const char *what) | 819 | static int parse_line_num(char **ptr, int *val, const char *what) |
798 | { | 820 | { |
799 | const char *start = *ptr; | 821 | const char *start = *ptr; |
diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h index d481c46e0796..fcaf7273e85a 100644 --- a/tools/perf/util/probe-event.h +++ b/tools/perf/util/probe-event.h | |||
@@ -120,6 +120,12 @@ extern void clear_perf_probe_event(struct perf_probe_event *pev); | |||
120 | /* Command string to line-range */ | 120 | /* Command string to line-range */ |
121 | extern int parse_line_range_desc(const char *cmd, struct line_range *lr); | 121 | extern int parse_line_range_desc(const char *cmd, struct line_range *lr); |
122 | 122 | ||
123 | /* Release line range members */ | ||
124 | extern void line_range__clear(struct line_range *lr); | ||
125 | |||
126 | /* Initialize line range */ | ||
127 | extern void line_range__init(struct line_range *lr); | ||
128 | |||
123 | /* Internal use: Return kernel/module path */ | 129 | /* Internal use: Return kernel/module path */ |
124 | extern const char *kernel_get_module_path(const char *module); | 130 | extern const char *kernel_get_module_path(const char *module); |
125 | 131 | ||