From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752507AbbCXN7f (ORCPT ); Tue, 24 Mar 2015 09:59:35 -0400 Received: from mail.kernel.org ([198.145.29.136]:44692 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752205AbbCXN70 (ORCPT ); Tue, 24 Mar 2015 09:59:26 -0400 Message-Id: <20150324135922.549965495@goodmis.org> User-Agent: quilt/0.61-1 Date: Tue, 24 Mar 2015 09:57:49 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Arnaldo Carvalho de Melo , Ingo Molnar , Jiri Olsa , Namhyung Kim , Andrew Morton , Josef Bacik Subject: [PATCH 1/9] tools lib traceevent: Handle NULL comm name References: <20150324135748.506437888@goodmis.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=0001-tools-lib-traceevent-Handle-NULL-comm-name.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Josef Bacik 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. Link: http://lkml.kernel.org/p/1403799732-30308-1-git-send-email-jbacik@fb.com Signed-off-by: Josef Bacik Signed-off-by: Steven Rostedt --- tools/lib/traceevent/event-parse.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index d7c37a7d9255..fdcb89be5e67 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; -- 2.1.4