tracing/filters: always free pred on filter_add_subsystem_pred() failure
PATCH 1/1 tracing/filters: always free pred on filter_add_subsystem_pred() failure
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.
--- kernel/trace/trace_events_filter.c | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-)
kernel/trace/trace_events_filter.c +11 -5
@@ -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)
@@ -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; }
@@ -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;
@@ -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;
Signature · 1 line
1.5.6.3
Quoted 3 lines · Tom Zanussi
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.
thanks, i've queued this up for .31.
Just to make sure: tracing/core has the filter code changed substantially, and this issue seems to be moot there - correct?
So the total impact from both patches on -tip is the patch below - right?
Ingo
kernel/trace/trace_events_filter.c +2 -0
@@ -1050,6 +1050,8 @@ static int replace_preds(struct event_subsystem *system, pred =create_pred (elt->op, operand1, operand2); add_pred: +if (!pred) +return -ENOMEM ;if (call) err =filter_add_pred (ps, call, pred, false);else
Quoted 11 lines · Ingo Molnar
Quoted 3 lines · Tom Zanussi
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.thanks, i've queued this up for .31.
Just to make sure: tracing/core has the filter code changed substantially, and this issue seems to be moot there - correct?
Right, the subsystem preds are gone in tip, so nothing to fix there.
Quoted 3 lines
So the total impact from both patches on -tip is the patch below - right?
Right.
Tom
Quoted 15 lines
Ingo
kernel/trace/trace_events_filter.c +2
-0@@ -1050,6 +1050,8 @@ static int replace_preds(struct event_subsystem *system, pred =create_pred (elt->op, operand1, operand2); add_pred: +if (!pred) +return -ENOMEM ;if (call) err =filter_add_pred (ps, call, pred, false);else
[tip:tracing/core] tracing/filters: Always free pred on filter_add_subsystem_pred() failure
In reply to Tom ZanussiCommit-ID: 26528e773ecc74fb1b61b7275f86f761cbb340ec Gitweb: http://git.kernel.org/tip/26528e773ecc74fb1b61b7275f86f761cbb340ec Author: Tom Zanussi <[email protected]> AuthorDate: Sat, 8 Aug 2009 10:49:53 -0500 Committer: Ingo Molnar <[email protected]> CommitDate: Sat, 8 Aug 2009 17:56:13 +0200
tracing/filters: Always free pred on filter_add_subsystem_pred() failure
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.
LKML-Reference: <1249746593.6453.32.camel@tropicana>
--- kernel/trace/trace_events_filter.c | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-)
kernel/trace/trace_events_filter.c +11 -5
@@ -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)
@@ -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; }
@@ -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;
@@ -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;