All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Bristot de Oliveira <bristot@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Daniel Bristot de Oliveira <bristot@kernel.org>,
	linux-kernel@vger.kernel.org, linux-trace-devel@vger.kernel.org
Subject: [PATCH 5/8] rtla/timerlat_top: Fix segmentation fault when failing to enable -t
Date: Mon, 24 Jan 2022 15:24:08 +0100	[thread overview]
Message-ID: <2fea7678dda97e09ef80fd5775abf51fc105a857.1643033113.git.bristot@kernel.org> (raw)
In-Reply-To: <cover.1643033113.git.bristot@kernel.org>

rtla timerlat top is causing a segmentation fault when running with
the --trace option on a kernel that does not support multiple
instances. For example:

    [root@f34 rtla]# rtla timerlat top -t
    failed to enable the tracer timerlat
    Could not enable osnoiser tracer for tracing
    Failed to enable the trace instance
    Segmentation fault (core dumped)

This error happens because the exit code of the tools is trying
to destroy the trace instance that failed to be created.

Rearrange the order in which trace instances are destroyed to avoid
this problem.

Fixes: a828cd18bc4a ("rtla: Add timerlat tool and timelart top mode")
Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org
Cc: linux-trace-devel@vger.kernel.org
Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
---
 tools/tracing/rtla/src/timerlat_top.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c
index 1ebd5291539c..323fd1f88313 100644
--- a/tools/tracing/rtla/src/timerlat_top.c
+++ b/tools/tracing/rtla/src/timerlat_top.c
@@ -584,7 +584,7 @@ int timerlat_top_main(int argc, char *argv[])
 						    trace);
 		if (retval < 0) {
 			err_msg("Error iterating on events\n");
-			goto out_top;
+			goto out_trace;
 		}
 
 		if (!params->quiet)
@@ -606,12 +606,12 @@ int timerlat_top_main(int argc, char *argv[])
 			save_trace_to_file(record->trace.inst, params->trace_output);
 		}
 	}
-
+out_trace:
+	if (params->trace_output)
+		osnoise_destroy_tool(record);
 out_top:
 	timerlat_free_top(top->data);
 	osnoise_destroy_tool(top);
-	if (params->trace_output)
-		osnoise_destroy_tool(record);
 	free(params);
 out_exit:
 	exit(return_value);
-- 
2.34.1


  parent reply	other threads:[~2022-01-24 14:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1643033113.git.bristot@kernel.org>
2022-01-24 14:24 ` [PATCH 1/8] rtla: Follow kernel version Daniel Bristot de Oliveira
2022-01-24 14:24 ` [PATCH 2/8] rtla/utils: Fix session duration parsing Daniel Bristot de Oliveira
2022-01-24 14:24 ` [PATCH 3/8] rtla/osnoise_top: Fix segmentation fault when failing to enable -t Daniel Bristot de Oliveira
2022-02-03 16:41   ` Steven Rostedt
2022-02-03 16:43     ` Steven Rostedt
2022-02-03 17:30       ` Daniel Bristot de Oliveira
2022-02-03 17:56         ` Steven Rostedt
2022-01-24 14:24 ` [PATCH 4/8] rtla/osnoise_hist: " Daniel Bristot de Oliveira
2022-01-24 14:24 ` Daniel Bristot de Oliveira [this message]
2022-01-24 14:24 ` [PATCH 6/8] rtla/timerlat_hist: " Daniel Bristot de Oliveira
2022-01-24 14:24 ` [PATCH 7/8] rtla/osnoise: Fix error message when failing to enable trace instance Daniel Bristot de Oliveira
2022-01-24 14:24 ` [PATCH 8/8] rtla/trace: Error message fixup Daniel Bristot de Oliveira

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2fea7678dda97e09ef80fd5775abf51fc105a857.1643033113.git.bristot@kernel.org \
    --to=bristot@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.