[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/16] cpu: fix memleak of 'halt_cond' and 'thread'
From: |
Michael Tokarev |
Subject: |
[PULL 02/16] cpu: fix memleak of 'halt_cond' and 'thread' |
Date: |
Sun, 30 Jun 2024 19:53:12 +0300 |
From: Matheus Tavares Bernardino <quic_mathbern@quicinc.com>
Since a4c2735f35 (cpu: move Qemu[Thread|Cond] setup into common code,
2024-05-30) these fields are now allocated at cpu_common_initfn(). So
let's make sure we also free them at cpu_common_finalize().
Furthermore, the code also frees these on round robin, but we missed
'halt_cond'.
Signed-off-by: Matheus Tavares Bernardino <quic_mathbern@quicinc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
accel/tcg/tcg-accel-ops-rr.c | 1 +
hw/core/cpu-common.c | 3 +++
2 files changed, 4 insertions(+)
diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c
index 84c36c1450..48c38714bd 100644
--- a/accel/tcg/tcg-accel-ops-rr.c
+++ b/accel/tcg/tcg-accel-ops-rr.c
@@ -329,6 +329,7 @@ void rr_start_vcpu_thread(CPUState *cpu)
/* we share the thread, dump spare data */
g_free(cpu->thread);
qemu_cond_destroy(cpu->halt_cond);
+ g_free(cpu->halt_cond);
cpu->thread = single_tcg_cpu_thread;
cpu->halt_cond = single_tcg_halt_cond;
diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
index bf1a7b8892..f131cde2c0 100644
--- a/hw/core/cpu-common.c
+++ b/hw/core/cpu-common.c
@@ -286,6 +286,9 @@ static void cpu_common_finalize(Object *obj)
g_array_free(cpu->gdb_regs, TRUE);
qemu_lockcnt_destroy(&cpu->in_ioctl_lock);
qemu_mutex_destroy(&cpu->work_mutex);
+ qemu_cond_destroy(cpu->halt_cond);
+ g_free(cpu->halt_cond);
+ g_free(cpu->thread);
}
static int64_t cpu_common_get_arch_id(CPUState *cpu)
--
2.39.2
- [PULL 00/16] Trivial patches for 2024-06-30, Michael Tokarev, 2024/06/30
- [PULL 01/16] hmp-commands-info.hx: Add missing info command for stats subcommand, Michael Tokarev, 2024/06/30
- [PULL 02/16] cpu: fix memleak of 'halt_cond' and 'thread',
Michael Tokarev <=
- [PULL 04/16] target/i386: Advertise MWAIT iff host supports, Michael Tokarev, 2024/06/30
- [PULL 05/16] monitor: Remove obsolete stubs, Michael Tokarev, 2024/06/30
- [PULL 03/16] vl: Allow multiple -overcommit commands, Michael Tokarev, 2024/06/30
- [PULL 06/16] linux-user: cris: Remove unused struct 'rt_signal_frame', Michael Tokarev, 2024/06/30
- [PULL 07/16] linux-user: sparc: Remove unused struct 'target_mc_fq', Michael Tokarev, 2024/06/30
- [PULL 08/16] hw/arm/bcm2836: Remove unusued struct 'BCM283XClass', Michael Tokarev, 2024/06/30
- [PULL 09/16] net/can: Remove unused struct 'CanBusState', Michael Tokarev, 2024/06/30
- [PULL 10/16] os-posix: Expand setrlimit() syscall compatibility, Michael Tokarev, 2024/06/30
- [PULL 11/16] docs/cxl: fix some typos, Michael Tokarev, 2024/06/30
- [PULL 12/16] docs/system/devices/usb: Replace the non-existing "qemu" binary, Michael Tokarev, 2024/06/30