]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
contrib/plugins/execlog: Explicitly check for qemu_plugin_read_register() failure
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 22 Sep 2025 09:37:01 +0000 (10:37 +0100)
committerAlex Bennée <alex.bennee@linaro.org>
Fri, 26 Sep 2025 09:07:54 +0000 (10:07 +0100)
In insn_check_regs() we don't explicitly check whether
qemu_plugin_read_register() failed, which confuses Coverity into
thinking that sz can be -1 in the memcmp().  In fact the assertion
that sz == reg->last->len means this can't happen, but it's clearer
to both humans and Coverity if we explicitly assert that sz > 0, as
we already do in init_vcpu_register().

Coverity: CID 16119011611902
Fixes: af6e4e0a22c1 ("contrib/plugins: extend execlog to track register changes")
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20250710144543.1187715-1-peter.maydell@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250922093711.2768983-17-alex.bennee@linaro.org>

contrib/plugins/execlog.c

index 06ec76d6e9a354615a052629e6f2550c06d7ce36..811f32031994c3da2f8d90c8963ef8dc10f8784b 100644 (file)
@@ -95,6 +95,7 @@ static void insn_check_regs(CPU *cpu)
 
         g_byte_array_set_size(reg->new, 0);
         sz = qemu_plugin_read_register(reg->handle, reg->new);
+        g_assert(sz > 0);
         g_assert(sz == reg->last->len);
 
         if (memcmp(reg->last->data, reg->new->data, sz)) {