aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosef Bacik <[email protected]>2015-03-24 09:57:49 -0400
committerArnaldo Carvalho de Melo <[email protected]>2015-03-24 12:10:26 -0300
commitdeab6f55a2fe6fe044af61c9aad6a8e90cda6499 (patch)
tree131825bb2a4620b0d06341cca9934c5603244c60
parent18425f13a0890ac1e88a64276771c1ae10030b4a (diff)
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 <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Link: http://lkml.kernel.org/p/[email protected] Signed-off-by: Steven Rostedt <[email protected]> Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
-rw-r--r--tools/lib/traceevent/event-parse.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 8e5e4f6137bb..31d4e7da191c 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -304,7 +304,10 @@ int pevent_register_comm(struct pevent *pevent, const char *comm, int pid)
if (!item)
return -1;
- item->comm = strdup(comm);
+ if (comm)
+ item->comm = strdup(comm);
+ else
+ item->comm = strdup("<...>");
if (!item->comm) {
free(item);
return -1;