]> rtime.felk.cvut.cz Git - linux-imx.git/blobdiff - kernel/trace/trace_event_perf.c
tracing/perf: Move the PERF_MAX_TRACE_SIZE check into perf_trace_buf_prepare()
[linux-imx.git] / kernel / trace / trace_event_perf.c
index 84b1e045faba836583fb371d285f49e79bfa6bd0..80c36bcf66e8e8d089776ff14b780f3f85efa418 100644 (file)
@@ -236,6 +236,10 @@ __kprobes void *perf_trace_buf_prepare(int size, unsigned short type,
 
        BUILD_BUG_ON(PERF_MAX_TRACE_SIZE % sizeof(unsigned long));
 
+       if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE,
+                       "perf buffer not large enough"))
+               return NULL;
+
        pc = preempt_count();
 
        *rctxp = perf_swevent_get_recursion_context();
@@ -266,6 +270,10 @@ perf_ftrace_function_call(unsigned long ip, unsigned long parent_ip,
        struct pt_regs regs;
        int rctx;
 
+       head = this_cpu_ptr(event_function.perf_events);
+       if (hlist_empty(head))
+               return;
+
 #define ENTRY_SIZE (ALIGN(sizeof(struct ftrace_entry) + sizeof(u32), \
                    sizeof(u64)) - sizeof(u32))
 
@@ -279,8 +287,6 @@ perf_ftrace_function_call(unsigned long ip, unsigned long parent_ip,
 
        entry->ip = ip;
        entry->parent_ip = parent_ip;
-
-       head = this_cpu_ptr(event_function.perf_events);
        perf_trace_buf_submit(entry, ENTRY_SIZE, rctx, 0,
                              1, &regs, head, NULL);