]> Pileus Git - ~andy/linux/blobdiff - kernel/trace/trace_event_profile.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6
[~andy/linux] / kernel / trace / trace_event_profile.c
index 3aaa77c3309bbc7109a8da1a11ecb71567a53be9..8d5c171cc9987d924f9fcfd3328fcb966288b9a0 100644 (file)
 typedef struct {char buf[FTRACE_MAX_PROFILE_SIZE];} profile_buf_t;
 
 char           *trace_profile_buf;
-char           *trace_profile_buf_nmi;
+EXPORT_SYMBOL_GPL(trace_profile_buf);
+
+char           *trace_profile_buf_nmi;
+EXPORT_SYMBOL_GPL(trace_profile_buf_nmi);
 
 /* Count the events in use (per event id, not per instance) */
 static int     total_profile_count;
@@ -28,7 +31,7 @@ static int ftrace_profile_enable_event(struct ftrace_event_call *event)
        if (atomic_inc_return(&event->profile_count))
                return 0;
 
-       if (!total_profile_count++) {
+       if (!total_profile_count) {
                buf = (char *)alloc_percpu(profile_buf_t);
                if (!buf)
                        goto fail_buf;
@@ -43,14 +46,19 @@ static int ftrace_profile_enable_event(struct ftrace_event_call *event)
        }
 
        ret = event->profile_enable();
-       if (!ret)
+       if (!ret) {
+               total_profile_count++;
                return 0;
+       }
 
-       kfree(trace_profile_buf_nmi);
 fail_buf_nmi:
-       kfree(trace_profile_buf);
+       if (!total_profile_count) {
+               free_percpu(trace_profile_buf_nmi);
+               free_percpu(trace_profile_buf);
+               trace_profile_buf_nmi = NULL;
+               trace_profile_buf = NULL;
+       }
 fail_buf:
-       total_profile_count--;
        atomic_dec(&event->profile_count);
 
        return ret;