linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] trace-cmd: handle NULL comm name in .dat file
@ 2014-06-26 16:22 Josef Bacik
  2014-06-27 20:21 ` Steven Rostedt
  0 siblings, 1 reply; 2+ messages in thread
From: Josef Bacik @ 2014-06-26 16:22 UTC (permalink / raw)
  To: linux-kernel, rostedt

Sometimes the comm field in the trace.dat file can be empty which means that the
event parsing stuff can pass a NULL into pevent_register_comm.  To fix this just
check if we are NULL and generate a bogus comm name for that PID.  This keeps us
from segfaulting.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 event-parse.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/event-parse.c b/event-parse.c
index 18b3587..00304fe 100644
--- a/event-parse.c
+++ b/event-parse.c
@@ -303,7 +303,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.0.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] trace-cmd: handle NULL comm name in .dat file
  2014-06-26 16:22 [PATCH] trace-cmd: handle NULL comm name in .dat file Josef Bacik
@ 2014-06-27 20:21 ` Steven Rostedt
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2014-06-27 20:21 UTC (permalink / raw)
  To: Josef Bacik; +Cc: linux-kernel

On Thu, 26 Jun 2014 09:22:12 -0700
Josef Bacik <jbacik@fb.com> wrote:

> Sometimes the comm field in the trace.dat file can be empty which means that the
> event parsing stuff can pass a NULL into pevent_register_comm.  To fix this just
> check if we are NULL and generate a bogus comm name for that PID.  This keeps us
> from segfaulting.  Thanks,
> 
> Signed-off-by: Josef Bacik <jbacik@fb.com>

Applied, thanks!

-- Steve

> ---
>  event-parse.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/event-parse.c b/event-parse.c
> index 18b3587..00304fe 100644
> --- a/event-parse.c
> +++ b/event-parse.c
> @@ -303,7 +303,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;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-06-27 20:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-26 16:22 [PATCH] trace-cmd: handle NULL comm name in .dat file Josef Bacik
2014-06-27 20:21 ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).