lkml.org 
[lkml]   [2018]   [Jul]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] tracing/kprobe: Release kprobe print_fmt properly
On Mon,  9 Jul 2018 16:19:06 +0200
Jiri Olsa <jolsa@kernel.org> wrote:

> We don't release tk->tp.call.print_fmt when destroying
> local uprobe. Also there's missing print_fmt kfree in
> create_local_trace_kprobe error path.
>
> Fixes: e12f03d7031a ("perf/core: Implement the 'perf_kprobe' PMU")
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>

Thanks for the patch, I'm applying it now (and testing it).

> ---
> kernel/trace/trace_kprobe.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
> index daa81571b22a..21f718472942 100644
> --- a/kernel/trace/trace_kprobe.c
> +++ b/kernel/trace/trace_kprobe.c
> @@ -1480,8 +1480,10 @@ create_local_trace_kprobe(char *func, void *addr, unsigned long offs,
> }
>
> ret = __register_trace_kprobe(tk);
> - if (ret < 0)
> + if (ret < 0) {
> + kfree(tk->tp.call.print_fmt);
> goto error;
> + }
>
> return &tk->tp.call;
> error:
> @@ -1501,6 +1503,8 @@ void destroy_local_trace_kprobe(struct trace_event_call *event_call)
> }
>
> __unregister_trace_kprobe(tk);
> +
> + kfree(tk->tp.call.print_fmt);

Bah! The naming convention of "set_print_fmt()" is horrible, and leads
to these kinds of bugs. I'll make a patch (not for stable though) that
makes it a bit more obvious to what is happening.

-- Steve


> free_trace_kprobe(tk);
> }
> #endif /* CONFIG_PERF_EVENTS */

\
 
 \ /
  Last update: 2018-07-09 18:45    [W:0.095 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site