From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755288AbbCXQdi (ORCPT ); Tue, 24 Mar 2015 12:33:38 -0400 Received: from terminus.zytor.com ([198.137.202.10]:56887 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752593AbbCXQdc (ORCPT ); Tue, 24 Mar 2015 12:33:32 -0400 Date: Tue, 24 Mar 2015 09:33:10 -0700 From: tip-bot for Josef Bacik Message-ID: Cc: namhyung@kernel.org, acme@redhat.com, mingo@kernel.org, jolsa@redhat.com, linux-kernel@vger.kernel.org, jbacik@fb.com, akpm@linux-foundation.org, rostedt@goodmis.org, hpa@zytor.com, tglx@linutronix.de Reply-To: tglx@linutronix.de, rostedt@goodmis.org, hpa@zytor.com, jbacik@fb.com, akpm@linux-foundation.org, namhyung@kernel.org, acme@redhat.com, mingo@kernel.org, jolsa@redhat.com, linux-kernel@vger.kernel.org In-Reply-To: <20150324135922.549965495@goodmis.org> References: <20150324135922.549965495@goodmis.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] tools lib traceevent: Handle NULL comm name Git-Commit-ID: deab6f55a2fe6fe044af61c9aad6a8e90cda6499 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: deab6f55a2fe6fe044af61c9aad6a8e90cda6499 Gitweb: http://git.kernel.org/tip/deab6f55a2fe6fe044af61c9aad6a8e90cda6499 Author: Josef Bacik AuthorDate: Tue, 24 Mar 2015 09:57:49 -0400 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 24 Mar 2015 12:10:26 -0300 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 Cc: Andrew Morton Cc: Jiri Olsa Cc: Namhyung Kim 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 Signed-off-by: Arnaldo Carvalho de Melo --- 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 8e5e4f6..31d4e7d 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;