Re: [PATCH 3/3] perf, stat: Fix free memory access / memory leaks in metrics

2019-09-24 Thread Arnaldo Carvalho de Melo
Em Tue, Sep 24, 2019 at 04:44:18PM +0200, Jiri Olsa escreveu: > On Tue, Sep 24, 2019 at 07:08:56AM -0700, Andi Kleen wrote: > > > > expr__ctx_init(); > > > > + /* Must be first id entry */ > > > > + expr__add_id(, name, avg); > > > > > > hum, shouldn't u instead use

Re: [PATCH 3/3] perf, stat: Fix free memory access / memory leaks in metrics

2019-09-24 Thread Jiri Olsa
On Tue, Sep 24, 2019 at 07:08:56AM -0700, Andi Kleen wrote: > > > expr__ctx_init(); > > > + /* Must be first id entry */ > > > + expr__add_id(, name, avg); > > > > hum, shouldn't u instead use strdup(name) instead of name? > > The cleanup loop later skips freeing the first entry. aaah, nice

Re: [PATCH 3/3] perf, stat: Fix free memory access / memory leaks in metrics

2019-09-24 Thread Andi Kleen
> > expr__ctx_init(); > > + /* Must be first id entry */ > > + expr__add_id(, name, avg); > > hum, shouldn't u instead use strdup(name) instead of name? The cleanup loop later skips freeing the first entry. -Andi

Re: [PATCH 3/3] perf, stat: Fix free memory access / memory leaks in metrics

2019-09-24 Thread Jiri Olsa
On Mon, Sep 23, 2019 at 04:33:39PM -0700, Andi Kleen wrote: > From: Andi Kleen > > Make sure to not free the name passed in by the caller, but free > all the allocated ids when parsing expressions. > > The loop at the end knows that the first entry shouldn't be freed, > so make sure the caller

[PATCH 3/3] perf, stat: Fix free memory access / memory leaks in metrics

2019-09-23 Thread Andi Kleen
From: Andi Kleen Make sure to not free the name passed in by the caller, but free all the allocated ids when parsing expressions. The loop at the end knows that the first entry shouldn't be freed, so make sure the caller name is the first entry. Fixes % perf stat -M