Re: [PATCH v3 6/7] tracing: Add snapshot action

From: Namhyung Kim
Date: Fri Aug 10 2018 - 03:04:09 EST


On Thu, Aug 09, 2018 at 09:34:16AM -0500, Tom Zanussi wrote:
> From: Tom Zanussi <tom.zanussi@xxxxxxxxxxxxxxx>
>
> 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 <tom.zanussi@xxxxxxxxxxxxxxx>
> ---

[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.

Thanks,
Namhyung


> + return ERR_PTR(-ENOMEM);
> + }
> +
> + data->elt.private_data = elt_data;
> +
> + return data;
> +}