]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
plugins: Free CPUPluginState before destroying vCPU state
authorPhilippe Mathieu-Daudé <philmd@linaro.org>
Fri, 5 Jul 2024 08:40:35 +0000 (09:40 +0100)
committerAlex Bennée <alex.bennee@linaro.org>
Fri, 5 Jul 2024 11:34:52 +0000 (12:34 +0100)
cpu::plugin_state is allocated in cpu_common_initfn() when
the vCPU state is created. Release it in cpu_common_finalize()
when we are done.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240606124010.2460-3-philmd@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240705084047.857176-29-alex.bennee@linaro.org>

hw/core/cpu-common.c
include/qemu/plugin.h

index f131cde2c038ec716b3889520bdf4b3819384edd..8f6cb64da3bfb89a0c8953c2eb22bf46035fa393 100644 (file)
@@ -283,6 +283,11 @@ static void cpu_common_finalize(Object *obj)
 {
     CPUState *cpu = CPU(obj);
 
+#ifdef CONFIG_PLUGIN
+    if (tcg_enabled()) {
+        g_free(cpu->plugin_state);
+    }
+#endif
     g_array_free(cpu->gdb_regs, TRUE);
     qemu_lockcnt_destroy(&cpu->in_ioctl_lock);
     qemu_mutex_destroy(&cpu->work_mutex);
index bc5aef979e718bbe4fbd00cba31aa9fda50399f1..af5f9db4692a329203d359b4bc875e7ff9b0fc55 100644 (file)
@@ -149,6 +149,9 @@ struct CPUPluginState {
 
 /**
  * qemu_plugin_create_vcpu_state: allocate plugin state
+ *
+ * The returned data must be released with g_free()
+ * when no longer required.
  */
 CPUPluginState *qemu_plugin_create_vcpu_state(void);