tracing: Adding NULL checks for trace_array descriptor pointer
authorDivya Indi <divya.indi@oracle.com>
Wed, 14 Aug 2019 17:55:25 +0000 (10:55 -0700)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Wed, 13 Nov 2019 14:37:29 +0000 (09:37 -0500)
As part of commit f45d1225adb0 ("tracing: Kernel access to Ftrace
instances") we exported certain functions. Here, we are adding some additional
NULL checks to ensure safe usage by users of these APIs.

Link: http://lkml.kernel.org/r/1565805327-579-4-git-send-email-divya.indi@oracle.com
Signed-off-by: Divya Indi <divya.indi@oracle.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/trace.c
kernel/trace/trace_events.c

index fa4f742fc449ab93c2cf7c30e1dec896015dba43..79fe4d6ecbd81173f603e768a98adbcad1016d22 100644 (file)
@@ -3297,6 +3297,9 @@ int trace_array_printk(struct trace_array *tr,
        if (!(global_trace.trace_flags & TRACE_ITER_PRINTK))
                return 0;
 
+       if (!tr)
+               return -ENOENT;
+
        va_start(ap, fmt);
        ret = trace_array_vprintk(tr, ip, fmt, ap);
        va_end(ap);
index fba87d10f0c1af1ab9367a981667cc452efd4707..2a3ac2365445295e65b8625b404db8b682c3a0df 100644 (file)
@@ -793,6 +793,8 @@ int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set)
        char *event = NULL, *sub = NULL, *match;
        int ret;
 
+       if (!tr)
+               return -ENOENT;
        /*
         * The buf format can be <subsystem>:<event-name>
         *  *:<event-name> means any event by that name.