Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools lib traceevent: Handle NULL comm name

It is possible that a pid has no associated comm attached to it, although it
can still be passed to pevent_register_comm().

But if comm is NULL, it will cause strdup() to segfault. To prevent this
from happening, if comm is NULL use the default "<...>" name for the
pid.

Signed-off-by: Josef Bacik <jbacik@fb.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20150324135922.549965495@goodmis.org
Link: http://lkml.kernel.org/p/1403799732-30308-1-git-send-email-jbacik@fb.com
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Josef Bacik and committed by
Arnaldo Carvalho de Melo
deab6f55 18425f13

+4 -1
+4 -1
tools/lib/traceevent/event-parse.c
··· 304 304 if (!item) 305 305 return -1; 306 306 307 - item->comm = strdup(comm); 307 + if (comm) 308 + item->comm = strdup(comm); 309 + else 310 + item->comm = strdup("<...>"); 308 311 if (!item->comm) { 309 312 free(item); 310 313 return -1;