From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Zanussi Subject: Re: [PATCH v3 6/7] tracing: Add snapshot action Date: Fri, 10 Aug 2018 09:07:16 -0500 Message-ID: <1533910036.1918.12.camel@kernel.org> References: <20180810070404.GD479@sejong> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: rostedt@goodmis.org, tglx@linutronix.de, mhiramat@kernel.org, vedang.patel@intel.com, bigeasy@linutronix.de, joel@joelfernandes.org, mathieu.desnoyers@efficios.com, julia@ni.com, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, kernel-team@lge.com To: Namhyung Kim Return-path: In-Reply-To: <20180810070404.GD479@sejong> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-rt-users.vger.kernel.org On Fri, 2018-08-10 at 16:04 +0900, Namhyung Kim wrote: > On Thu, Aug 09, 2018 at 09:34:16AM -0500, Tom Zanussi wrote: > > From: Tom Zanussi > > > > Add support for hist:handlerXXX($var).snapshot(), which will take a > > snapshot of the current trace buffer whenever handlerXXX is hit. > > > > As a first user, this also adds snapshot() action support for the > > onmax() handler i.e. hist:onmax($var).snapshot(). > > > > Signed-off-by: Tom Zanussi > > --- > > [SNIP] > > +static struct track_data *track_data_alloc(unsigned int key_len, > > + struct action_data > > *action_data, > > + struct > > hist_trigger_data *hist_data) > > +{ > > + struct track_data *data = kzalloc(sizeof(*data), > > GFP_KERNEL); > > + unsigned int size = TASK_COMM_LEN; > > + struct hist_elt_data *elt_data; > > + > > + if (!data) > > + return ERR_PTR(-ENOMEM); > > + > > + data->key = kzalloc(key_len, GFP_KERNEL); > > + if (!data->key) { > > + track_data_free(data); > > + return ERR_PTR(-ENOMEM); > > + } > > + > > + data->key_len = key_len; > > + data->action_data = action_data; > > + data->hist_data = hist_data; > > + > > + elt_data = kzalloc(sizeof(*elt_data), GFP_KERNEL); > > + if (!elt_data) { > > + track_data_free(data); > > + return ERR_PTR(-ENOMEM); > > + } > > + elt_data->comm = kzalloc(size, GFP_KERNEL); > > + if (!elt_data->comm) { > > + track_data_free(data); > > It seems to leak 'elf_data' here. > Yep, it does - thanks for pointing that out. Tom > Thanks, > Namhyung > > > > + return ERR_PTR(-ENOMEM); > > + } > > + > > + data->elt.private_data = elt_data; > > + > > + return data; > > +}