[lttng-dev] [PATCH lttng-tools] Fix: Free new_chunk on error
Jonathan Rajotte-Julien
jonathan.rajotte-julien at efficios.com
Fri Sep 20 17:37:14 EDT 2019
On Fri, Sep 20, 2019 at 05:34:26PM -0400, Jérémie Galarneau wrote:
> Merged in master and stable-2.11.
>
> On Fri, Sep 20, 2019 at 10:47:30AM -0400, Jonathan Rajotte wrote:
> > Fixes coverity #1405775
> >
> > Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien at efficios.com>
> > ---
> > src/common/trace-chunk.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/src/common/trace-chunk.c b/src/common/trace-chunk.c
> > index 6770bd982..bad993bea 100644
> > --- a/src/common/trace-chunk.c
> > +++ b/src/common/trace-chunk.c
> > @@ -367,6 +367,8 @@ end:
> > return new_chunk;
> > error_unlock:
> > pthread_mutex_unlock(&source_chunk->lock);
> > + lttng_trace_chunk_fini(new_chunk);
> > + free(new_chunk);
>
> Changed this to lttng_trace_chunk_put(), which will drop the only
> existing reference to `new_chunk` and perform the equivalent
> operations to what you proposed here.
Okai, I saw a similar pattern somewhere in the file. Might want to check if the
same can be applied there.
>
> Thanks!
> Jérémie
>
> > return NULL;
> > }
> >
> > --
> > 2.17.1
> >
--
Jonathan Rajotte-Julien
EfficiOS
More information about the lttng-dev
mailing list