Commit 9e82b4a9 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'trace-v5.2-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace

Pull tracing fix from Steven Rostedt:
 "This fixes a memory leak from the error path in the event filter
  logic"

* tag 'trace-v5.2-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
  tracing: Avoid memory leak in predicate_parse()
parents 9fb67d64 dfb4a6f2
...@@ -428,7 +428,7 @@ predicate_parse(const char *str, int nr_parens, int nr_preds, ...@@ -428,7 +428,7 @@ predicate_parse(const char *str, int nr_parens, int nr_preds,
op_stack = kmalloc_array(nr_parens, sizeof(*op_stack), GFP_KERNEL); op_stack = kmalloc_array(nr_parens, sizeof(*op_stack), GFP_KERNEL);
if (!op_stack) if (!op_stack)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
prog_stack = kmalloc_array(nr_preds, sizeof(*prog_stack), GFP_KERNEL); prog_stack = kcalloc(nr_preds, sizeof(*prog_stack), GFP_KERNEL);
if (!prog_stack) { if (!prog_stack) {
parse_error(pe, -ENOMEM, 0); parse_error(pe, -ENOMEM, 0);
goto out_free; goto out_free;
...@@ -579,7 +579,11 @@ predicate_parse(const char *str, int nr_parens, int nr_preds, ...@@ -579,7 +579,11 @@ predicate_parse(const char *str, int nr_parens, int nr_preds,
out_free: out_free:
kfree(op_stack); kfree(op_stack);
kfree(inverts); kfree(inverts);
kfree(prog_stack); if (prog_stack) {
for (i = 0; prog_stack[i].pred; i++)
kfree(prog_stack[i].pred);
kfree(prog_stack);
}
return ERR_PTR(ret); return ERR_PTR(ret);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment