Re: [for-next][PATCH 6/6] tracing: Fix leak of ring buffer data when new instances creation fails

From: Steven Rostedt
Date: Tue Jun 10 2014 - 11:59:01 EST


On Tue, 10 Jun 2014 14:25:21 +0900
Namhyung Kim <namhyung@xxxxxxxxx> wrote:


> > +static void free_trace_buffers(struct trace_array *tr)
> > +{
> > + if (!tr)
> > + return;
> > +
> > + if (tr->trace_buffer.buffer) {
> > + ring_buffer_free(tr->trace_buffer.buffer);
> > + tr->trace_buffer.buffer = NULL;
> > + free_percpu(tr->trace_buffer.data);
> > + }
> > +
> > +#ifdef CONFIG_TRACER_MAX_TRACE
> > + if (tr->max_buffer.buffer) {
> > + ring_buffer_free(tr->max_buffer.buffer);
> > + tr->max_buffer.buffer = NULL;
>
> Hmm.. why doesn't it free tr->max_buffer.data here? And I think it's
> better to reset *_buffer.data to NULL also - maybe by adding another
> helper function free_trace_buffer()..
>

Originally, instances didn't need them. But I'm looking now and yes
they do allocate. I guess this doesn't trigger kmem-leak checks, as I
ran creation and deletions with that running and it didn't report any
leaks.

I'll update,

Thanks!

-- Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/