lkml.org 
[lkml]   [2009]   [Aug]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Subject[2.6.31 PATCH] tracing/filters: always free pred on filter_add_subsystem_pred() failure
    From
    Date
    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 <tzanussi@gmail.com>
    ---
    kernel/trace/trace_events_filter.c | 16 +++++++++++-----
    1 files changed, 11 insertions(+), 5 deletions(-)

    diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
    index 1557148..f32dc9d 100644
    --- a/kernel/trace/trace_events_filter.c
    +++ b/kernel/trace/trace_events_filter.c
    @@ -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;

    --
    1.5.6.3




    \
     
     \ /
      Last update: 2009-08-08 17:53    [W:0.023 / U:0.024 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site