aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (Google) <rostedt@goodmis.org>2022-07-07 19:16:21 -0400
committerSteven Rostedt (Google) <rostedt@goodmis.org>2022-07-08 14:41:41 -0400
commit528ff5f6c798d49015bbe500a555d971831371a0 (patch)
treee97839166aaa74e1cc71b9c1deb5057d639c509e
parentc716d2b4610ae86904d0658f11c0c1d34b1f5850 (diff)
downloadtrace-cmd-528ff5f6c798d49015bbe500a555d971831371a0.tar.gz
trace-cmd: Have tracecmd_write_guest_time_shift() handle NULL tsync
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. Link: https://lore.kernel.org/linux-trace-devel/20220707191621.77deba71@gandalf.local.home Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-rw-r--r--lib/trace-cmd/trace-timesync.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/trace-cmd/trace-timesync.c b/lib/trace-cmd/trace-timesync.c
index bc643098..75c27bab 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));