tracing: Have "enable" file use refcounts like the "filter"
commit788ae7963e9b103697d23a773dc1449533bf2e79
authorSteven Rostedt <srostedt@redhat.com>
Tue, 5 Jul 2011 18:32:51 +0000 (5 14:32 -0400)
committerAndi Kleen <ak@linux.intel.com>
Mon, 1 Aug 2011 20:55:03 +0000 (1 13:55 -0700)
treecdfd6e93f071e906cadde54602970dc94ef9fddb
parenteabdd90b949f20ce315896b5bdd985a571d1bd77
tracing: Have "enable" file use refcounts like the "filter"

[ upstream commit 40ee4dffff061399eb9358e0c8fcfbaf8de4c8fe ]
 file

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.

Cc: <stable@kernel.org>
Reported-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
kernel/trace/trace_events.c