From: Steven Rostedt <rostedt@goodmis.org>
To: Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Subject: [PATCH] trace-cmd: Have tracecmd_write_guest_time_shift() handle NULL tsync
Date: Thu, 7 Jul 2022 19:16:21 -0400 [thread overview]
Message-ID: <20220707191621.77deba71@gandalf.local.home> (raw)
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
If the clock_context_init() fails, the ctx->instance->tsync will be NULL,
but it may be used in calling tracecmd_write_guest_time_shift(). This will
cause a SEGFAULT as that function expects it to be non NULL.
Test for tsync not NULL and return -1 if it is.
More should be done to warn when this happens, but for now prevent the
SEGFAULT. This makes the code more robust.
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
lib/trace-cmd/trace-timesync.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/trace-cmd/trace-timesync.c b/lib/trace-cmd/trace-timesync.c
index bc6430983a96..75c27babfe43 100644
--- a/lib/trace-cmd/trace-timesync.c
+++ b/lib/trace-cmd/trace-timesync.c
@@ -835,7 +835,7 @@ int tracecmd_write_guest_time_shift(struct tracecmd_output *handle,
int i, j;
int ret = -1;
- if (!tsync->vcpu_count)
+ if (!tsync || !tsync->vcpu_count)
return -1;
vcount = 3 + (5 * tsync->vcpu_count);
vector = calloc(vcount, sizeof(struct iovec));
--
2.35.1
reply other threads:[~2022-07-07 23:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220707191621.77deba71@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=linux-trace-devel@vger.kernel.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 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).