OSDN Git Service

tracing: Have "enable" file use refcounts like the "filter" file
authorSteven Rostedt <srostedt@redhat.com>
Tue, 5 Jul 2011 18:32:51 +0000 (14:32 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 5 Aug 2011 04:58:38 +0000 (21:58 -0700)
commitff7b3dc6a634832a912445db8bffd18b05c15043
treef43c5cd10398a1c91f8ff6b061a8b663663d84fb
parentf35869d69b65ac9323a0d7ee13c062e1636d4a1b
tracing: Have "enable" file use refcounts like the "filter" file

commit 40ee4dffff061399eb9358e0c8fcfbaf8de4c8fe upstream.

The "enable" file for the event system can be removed when a module
is unloaded and the event system only has events from that module.
As the event system nr_events count goes to zero, it may be freed
if its ref_count is also set to zero.

Like the "filter" file, the "enable" file may be opened by a task and
referenced later, after a module has been unloaded and the events for
that event system have been removed.

Although the "filter" file referenced the event system structure,
the "enable" file only references a pointer to the event system
name. Since the name is freed when the event system is removed,
it is possible that an access to the "enable" file may reference
a freed pointer.

Update the "enable" file to use the subsystem_open() routine that
the "filter" file uses, to keep a reference to the event system
structure while the "enable" file is opened.

Reported-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
kernel/trace/trace_events.c