Skip to contentSkip to conversation

target/i386/hvf: Free ressources when vCPU is destroyed

PATCH-for-7.0 Philippe Mathieu-Daudé 2 participants 3 messages Mar 22, 2022 – Mar 24, 2022

lore
Share & tools
lore
#0 lore raw

From: Philippe Mathieu-Daudé <[email protected]>

Both xsave_buf and hvf_caps are allocated in hvf_arch_init_vcpu(), free them in hvf_arch_vcpu_destroy().

---
 target/i386/hvf/hvf.c | 2 ++
 1 file changed, 2 insertions(+)
target/i386/hvf/hvf.c +2 -0
index fc12c02fb2..39fa4641b9 100644
@@ -163,7 +163,9 @@ void hvf_arch_vcpu_destroy(CPUState *cpu)
     X86CPU *x86_cpu = X86_CPU(cpu);
     CPUX86State *env = &x86_cpu->env;
 
+    g_free(env->xsave_buf);
     g_free(env->hvf_mmio_buf);
+    g_free(hvf_state->hvf_caps);
 }
 
 static void init_tsc_freq(CPUX86State *env)
Signature · 1 line
2.35.1
#1 lore raw

Typo s/ressources/resources/ in subject.

Quoted 26 lines · Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

Both xsave_buf and hvf_caps are allocated in hvf_arch_init_vcpu(), free them in hvf_arch_vcpu_destroy().

---
  target/i386/hvf/hvf.c | 2 ++
  1 file changed, 2 insertions(+)
target/i386/hvf/hvf.c +2 -0
index fc12c02fb2..39fa4641b9 100644
@@ -163,7 +163,9 @@ void hvf_arch_vcpu_destroy(CPUState *cpu)
      X86CPU *x86_cpu = X86_CPU(cpu);
      CPUX86State *env = &x86_cpu->env;
 
+    g_free(env->xsave_buf);
      g_free(env->hvf_mmio_buf);
+    g_free(hvf_state->hvf_caps);
  }
 
  static void init_tsc_freq(CPUX86State *env)
Reviewed-by
#2 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 8 lines · On Tue, 22 Mar 2022 20:07:45 +0100 Philippe Mathieu-Daudé…

From: Philippe Mathieu-Daudé <[email protected]>

Both xsave_buf and hvf_caps are allocated in hvf_arch_init_vcpu(), free them in hvf_arch_vcpu_destroy().

Quoted 18 lines
---
 target/i386/hvf/hvf.c | 2 ++
 1 file changed, 2 insertions(+)
target/i386/hvf/hvf.c +2 -0
index fc12c02fb2..39fa4641b9 100644
@@ -163,7 +163,9 @@ void hvf_arch_vcpu_destroy(CPUState *cpu)
     X86CPU *x86_cpu = X86_CPU(cpu);
     CPUX86State *env = &x86_cpu->env;
 
+    g_free(env->xsave_buf);
     g_free(env->hvf_mmio_buf);
+    g_free(hvf_state->hvf_caps);
 }
 
 static void init_tsc_freq(CPUX86State *env)