Skip to content

Commit

Permalink
tracing/filters: return proper error code when writing filter file
Browse files Browse the repository at this point in the history
- propagate return value of filter_add_pred() to the user

- return -ENOSPC but not -ENOMEM or -EINVAL when the filter array
  is full

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Acked-by: Tom Zanussi <tzanussi@gmail.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <49E04CF0.3010105@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Li Zefan authored and Ingo Molnar committed Apr 12, 2009
1 parent a3e0ab0 commit 44e9c8b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions kernel/trace/trace_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,9 +521,10 @@ event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
return cnt;
}

if (filter_add_pred(call, pred)) {
err = filter_add_pred(call, pred);
if (err < 0) {
filter_free_pred(pred);
return -EINVAL;
return err;
}

*ppos += cnt;
Expand Down Expand Up @@ -588,10 +589,11 @@ subsystem_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
return cnt;
}

if (filter_add_subsystem_pred(system, pred)) {
err = filter_add_subsystem_pred(system, pred);
if (err < 0) {
filter_free_subsystem_preds(system);
filter_free_pred(pred);
return -EINVAL;
return err;
}

*ppos += cnt;
Expand Down
4 changes: 2 additions & 2 deletions kernel/trace/trace_events_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ static int __filter_add_pred(struct ftrace_event_call *call,
}
}

return -ENOMEM;
return -ENOSPC;
}

static int is_string_field(const char *type)
Expand Down Expand Up @@ -319,7 +319,7 @@ int filter_add_subsystem_pred(struct event_subsystem *system,
}

if (i == MAX_FILTER_PRED)
return -EINVAL;
return -ENOSPC;

events_for_each(call) {
int err;
Expand Down

0 comments on commit 44e9c8b

Please sign in to comment.