[lkml]   [2018]   [Jul]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH 1/3] [BUGFIX] tracing: Fix double free of event_trigger_data
On Tue, 24 Jul 2018 16:49:59 -0400
Steven Rostedt <> wrote:

> > Hmm it seems we should review the register_trigger() implementation.
> > It should return the return value of trace_event_trigger_enable_disable(),
> > shouldn't it?
> >
> Yeah, that's not done well. I'll fix it up.
> Thanks for pointing it out.


register_trigger() is messed up. I should have caught this when it was
first submitted, but I'm totally confused. The comments don't match the

First we have this:

ret = cmd_ops->reg(glob, trigger_ops, trigger_data, file);
* The above returns on success the # of functions enabled,
* but if it didn't find any functions it returns zero.
* Consider no functions a failure too.

Which looks to be total BS.

As we have this:

* register_trigger - Generic event_command @reg implementation
* @glob: The raw string used to register the trigger
* @ops: The trigger ops associated with the trigger
* @data: Trigger-specific data to associate with the trigger
* @file: The trace_event_file associated with the event
* Common implementation for event trigger registration.
* Usually used directly as the @reg method in event command
* implementations.
* Return: 0 on success, errno otherwise
static int register_trigger(char *glob, struct event_trigger_ops *ops,
struct event_trigger_data *data,
struct trace_event_file *file)
struct event_trigger_data *test;
int ret = 0;

list_for_each_entry_rcu(test, &file->triggers, list) {
if (test->cmd_ops->trigger_type == data->cmd_ops->trigger_type) {
ret = -EEXIST;
goto out;

if (data->ops->init) {
ret = data->ops->init(data->ops, data);
if (ret < 0)
goto out;

list_add_rcu(&data->list, &file->triggers);

if (trace_event_trigger_enable_disable(file, 1) < 0) {
return ret;

Where the comment is total wrong. It doesn't return 0 on success, it
returns 1. And if trace_event_trigger_enable_disable() fails it returns

And that can fail with the call->class->reg() return value, which could
fail for various strange reasons. I don't know why we would want to
return 0 when it fails?

I don't see where ->reg() would return anything but 1 on success. Maybe
I'm missing something. I'll look some more, but I'm thinking of changing
->reg() to return zero on all success, and negative on all errors and
just check those results.

-- Steve

 \ /
  Last update: 2018-07-24 23:31    [W:0.136 / U:1.880 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site