diff options
author | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2018-12-09 21:17:30 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-12-21 14:09:51 +0100 |
commit | 60ed7a77f8f90ba93fc12f8ddb86751fe8817428 (patch) | |
tree | 674658e54ef362edac1d184aa51b5f74d9341768 /kernel | |
parent | c046fa1ca387f39a4774eda5a825a0e1902ab6f8 (diff) | |
download | linux-stable-60ed7a77f8f90ba93fc12f8ddb86751fe8817428.tar.gz linux-stable-60ed7a77f8f90ba93fc12f8ddb86751fe8817428.tar.bz2 linux-stable-60ed7a77f8f90ba93fc12f8ddb86751fe8817428.zip |
tracing: Fix memory leak in set_trigger_filter()
commit 3cec638b3d793b7cacdec5b8072364b41caeb0e1 upstream.
When create_event_filter() fails in set_trigger_filter(), the filter may
still be allocated and needs to be freed. The caller expects the
data->filter to be updated with the new filter, even if the new filter
failed (we could add an error message by setting set_str parameter of
create_event_filter(), but that's another update).
But because the error would just exit, filter was left hanging and
nothing could free it.
Found by kmemleak detector.
Cc: stable@vger.kernel.org
Fixes: bac5fb97a173a ("tracing: Add and use generic set_trigger_filter() implementation")
Reviewed-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace_events_trigger.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c index b8a894adab2c..8be66a2b0cac 100644 --- a/kernel/trace/trace_events_trigger.c +++ b/kernel/trace/trace_events_trigger.c @@ -727,8 +727,10 @@ static int set_trigger_filter(char *filter_str, /* The filter is for the 'trigger' event, not the triggered event */ ret = create_event_filter(file->event_call, filter_str, false, &filter); - if (ret) - goto out; + /* + * If create_event_filter() fails, filter still needs to be freed. + * Which the calling code will do with data->filter. + */ assign: tmp = rcu_access_pointer(data->filter); |