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>
This commit is contained in:

committed by
Arnaldo Carvalho de Melo

parent
981d05adf2
commit
e53b00d382
@@ -794,6 +794,28 @@ int show_available_vars(struct perf_probe_event *pevs __maybe_unused,
|
||||
}
|
||||
#endif
|
||||
|
||||
void line_range__clear(struct line_range *lr)
|
||||
{
|
||||
struct line_node *ln;
|
||||
|
||||
free(lr->function);
|
||||
free(lr->file);
|
||||
free(lr->path);
|
||||
free(lr->comp_dir);
|
||||
while (!list_empty(&lr->line_list)) {
|
||||
ln = list_first_entry(&lr->line_list, struct line_node, list);
|
||||
list_del(&ln->list);
|
||||
free(ln);
|
||||
}
|
||||
memset(lr, 0, sizeof(*lr));
|
||||
}
|
||||
|
||||
void line_range__init(struct line_range *lr)
|
||||
{
|
||||
memset(lr, 0, sizeof(*lr));
|
||||
INIT_LIST_HEAD(&lr->line_list);
|
||||
}
|
||||
|
||||
static int parse_line_num(char **ptr, int *val, const char *what)
|
||||
{
|
||||
const char *start = *ptr;
|
||||
|
Reference in New Issue
Block a user