Re: [PATCH] trace: Avoid memory leak in predicate_parse()

From: Steven Rostedt
Date: Tue May 28 2019 - 16:34:31 EST


On Tue, 28 May 2019 17:43:38 +0200
Tomas Bortoli <tomasbortoli@xxxxxxxxx> wrote:

> @@ -578,6 +578,8 @@ predicate_parse(const char *str, int nr_parens, int nr_preds,
> out_free:
> kfree(op_stack);
> kfree(inverts);
> + for (i = 0; prog_stack[i].pred; i++)
> + kfree(prog_stack[i].pred);
> kfree(prog_stack);
> return ERR_PTR(ret);
> }

I should have caught this, but thanks to the zero day bot, it found it
first:

kernel/trace/trace_events_filter.c:582:27-31: ERROR: prog_stack is NULL but dereferenced.

I changed the patch with the following: