Skip to content

Commit

Permalink
tracing/filters: Always free pred on filter_add_subsystem_pred() failure
Browse files Browse the repository at this point in the history
If filter_add_subsystem_pred() fails due to ENOSPC or ENOMEM,
the pred doesn't get freed, while as a side effect it does for
other errors. Make it so the caller always frees the pred for
any error.

Signed-off-by: Tom Zanussi <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Li Zefan <[email protected]>
LKML-Reference: <1249746593.6453.32.camel@tropicana>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
zanussi authored and Ingo Molnar committed Aug 8, 2009
1 parent 96b2de3 commit 26528e7
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions kernel/trace/trace_events_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,9 +624,6 @@ static int filter_add_subsystem_pred(struct filter_parse_state *ps,
return -ENOSPC;
}

filter->preds[filter->n_preds] = pred;
filter->n_preds++;

list_for_each_entry(call, &ftrace_events, list) {

if (!call->define_fields)
Expand All @@ -643,6 +640,9 @@ static int filter_add_subsystem_pred(struct filter_parse_state *ps,
}
replace_filter_string(call->filter, filter_string);
}

filter->preds[filter->n_preds] = pred;
filter->n_preds++;
out:
return err;
}
Expand Down Expand Up @@ -1034,9 +1034,12 @@ static int replace_preds(struct event_subsystem *system,
if (call) {
err = filter_add_pred(ps, call, pred);
filter_free_pred(pred);
} else
} else {
err = filter_add_subsystem_pred(ps, system,
pred, filter_string);
if (err)
filter_free_pred(pred);
}
if (err)
return err;

Expand All @@ -1055,9 +1058,12 @@ static int replace_preds(struct event_subsystem *system,
if (call) {
err = filter_add_pred(ps, call, pred);
filter_free_pred(pred);
} else
} else {
err = filter_add_subsystem_pred(ps, system, pred,
filter_string);
if (err)
filter_free_pred(pred);
}
if (err)
return err;

Expand Down

0 comments on commit 26528e7

Please sign in to comment.