summaryrefslogtreecommitdiff
path: root/kernel/trace/trace_events_filter.c
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2011-07-05 15:36:06 (GMT)
committerSteven Rostedt <rostedt@goodmis.org>2011-07-07 15:19:18 (GMT)
commite9dbfae53eeb9fc3d4bb7da3df87fa9875f5da02 (patch)
tree2a389b9c6a5fe08d4fb3a9ca96e753244963e1d9 /kernel/trace/trace_events_filter.c
parent140fe3b1ab9c082182ef13359fab4ddba95c24c3 (diff)
downloadlinux-fsl-qoriq-e9dbfae53eeb9fc3d4bb7da3df87fa9875f5da02.tar.xz
tracing: Fix bug when reading system filters on module removal
The event system is freed when its nr_events is set to zero. This happens when a module created an event system and then later the module is removed. Modules may share systems, so the system is allocated when it is created and freed when the modules are unloaded and all the events under the system are removed (nr_events set to zero). The problem arises when a task opened the "filter" file for the system. If the module is unloaded and it removed the last event for that system, the system structure is freed. If the task that opened the filter file accesses the "filter" file after the system has been freed, the system will access an invalid pointer. By adding a ref_count, and using it to keep track of what is using the event system, we can free it after all users are finished with the event system. Cc: <stable@kernel.org> Reported-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace_events_filter.c')
-rw-r--r--kernel/trace/trace_events_filter.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 8008ddc..256764e 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -1886,6 +1886,12 @@ int apply_subsystem_event_filter(struct event_subsystem *system,
mutex_lock(&event_mutex);
+ /* Make sure the system still has events */
+ if (!system->nr_events) {
+ err = -ENODEV;
+ goto out_unlock;
+ }
+
if (!strcmp(strstrip(filter_string), "0")) {
filter_free_subsystem_preds(system);
remove_filter_string(system->filter);