]> git.karo-electronics.de Git - linux-beck.git/commitdiff
tracing: Add check for NULL event field when creating hist field
authorTom Zanussi <tom.zanussi@linux.intel.com>
Mon, 25 Apr 2016 19:01:27 +0000 (14:01 -0500)
committerSteven Rostedt <rostedt@goodmis.org>
Tue, 26 Apr 2016 13:40:29 +0000 (09:40 -0400)
Smatch flagged create_hist_field() as possibly being able to
dereference a NULL pointer, although the current code exits in all
cases where the event field could be NULL, so it's not actually a
problem.

Still, to prevent future changes to the code from overlooking new
cases, make the NULL pointer check explicit and warn once in that
case.

Link: http://lkml.kernel.org/r/cfbc003f534a3e441b4313272fd412310aba6336.1461610073.git.tom.zanussi@linux.intel.com
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/trace_events_hist.c

index f98b6b3a28042a76538d2a670fd22b9aacaf184d..0c05b8a9980646adcf61c8cbc13355b535334f72 100644 (file)
@@ -371,6 +371,9 @@ static struct hist_field *create_hist_field(struct ftrace_event_field *field,
                goto out;
        }
 
+       if (WARN_ON_ONCE(!field))
+               goto out;
+
        if (is_string_field(field)) {
                flags |= HIST_FIELD_FL_STRING;