tracing: Return -EBUSY when event_enable_func() fails to get module
authorMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Thu, 16 May 2013 11:48:49 +0000 (20:48 +0900)
committerSteven Rostedt <rostedt@goodmis.org>
Thu, 16 May 2013 15:01:16 +0000 (11:01 -0400)
Since try_module_get() returns false( = 0) when it fails to
pindown a module, event_enable_func() returns 0 which means
"succeed". This can cause a kernel panic when the entry
is removed, because the event is already released.

This fixes the bug by returning -EBUSY, because the reason
why it fails is that the module is being removed at that time.

Link: http://lkml.kernel.org/r/20130516114848.13508.97899.stgit@mhiramat-M0-7522
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Tom Zanussi <tom.zanussi@intel.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/trace_events.c

index 7a0cf68027ccf62118d4eb1da83ec00af3a0b49b..27963e2bf4bfe141d0884bbe9f05b0d74a7fcc47 100644 (file)
@@ -2072,8 +2072,10 @@ event_enable_func(struct ftrace_hash *hash,
  out_reg:
        /* Don't let event modules unload while probe registered */
        ret = try_module_get(file->event_call->mod);
-       if (!ret)
+       if (!ret) {
+               ret = -EBUSY;
                goto out_free;
+       }
 
        ret = __ftrace_event_enable_disable(file, 1, 1);
        if (ret < 0)