Re: [PATCH v5 02/14] perf tools: Prevent calling machine__delete() on non-allocated machine

2015-12-16 Thread Arnaldo Carvalho de Melo
Em Wed, Dec 16, 2015 at 09:37:18AM +0800, Wangnan (F) escreveu: > > > On 2015/12/15 20:36, Jiri Olsa wrote: > >On Mon, Dec 14, 2015 at 10:39:11AM +, Wang Nan wrote: > > > >SNIP > > > >>@@ -137,12 +138,15 @@ void machine__exit(struct machine *machine) > >> void machine__delete(struct machine

Re: [PATCH v5 02/14] perf tools: Prevent calling machine__delete() on non-allocated machine

2015-12-15 Thread Wangnan (F)
On 2015/12/15 20:36, Jiri Olsa wrote: On Mon, Dec 14, 2015 at 10:39:11AM +, Wang Nan wrote: SNIP @@ -137,12 +138,15 @@ void machine__exit(struct machine *machine) void machine__delete(struct machine *machine) { machine__exit(machine); - free(machine); + if (machin

Re: [PATCH v5 02/14] perf tools: Prevent calling machine__delete() on non-allocated machine

2015-12-15 Thread Jiri Olsa
On Mon, Dec 14, 2015 at 10:39:11AM +, Wang Nan wrote: SNIP > @@ -137,12 +138,15 @@ void machine__exit(struct machine *machine) > void machine__delete(struct machine *machine) > { > machine__exit(machine); > - free(machine); > + if (machine->allocated) > + free(mach

[PATCH v5 02/14] perf tools: Prevent calling machine__delete() on non-allocated machine

2015-12-14 Thread Wang Nan
To prevent futher commits calling machine__delete() on non-allocated 'struct machine' (which would cause memory corruption), this patch enforces machine__init(), record whether a machine structure is dynamically allocated or not, and warn if machine__delete() is called on incorrect object. Signed-