qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Phil Dennis-Jordan <phil@philjordan.eu>
To: qemu-devel@nongnu.org
Cc: dirty@apple.com, rbolshakov@ddn.com, pbonzini@redhat.com,
	Phil Dennis-Jordan <phil@philjordan.eu>
Subject: [PATCH 3/5] i386/hvf: Fixes startup memory leak (vmcs caps)
Date: Tue,  5 Nov 2024 16:57:58 +0100	[thread overview]
Message-ID: <20241105155800.5461-4-phil@philjordan.eu> (raw)
In-Reply-To: <20241105155800.5461-1-phil@philjordan.eu>

The hvf_caps data structure only exists once as part of the hvf accelerator
state, but it is initialised during vCPU initialisation. This change therefore
adds a check to ensure memory for it is only allocated once.

Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
---
 target/i386/hvf/hvf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c
index 68dc5d9cf75..8527bce6eef 100644
--- a/target/i386/hvf/hvf.c
+++ b/target/i386/hvf/hvf.c
@@ -239,7 +239,9 @@ int hvf_arch_init_vcpu(CPUState *cpu)
     init_emu();
     init_decoder();
 
-    hvf_state->hvf_caps = g_new0(struct hvf_vcpu_caps, 1);
+    if (hvf_state->hvf_caps == NULL) {
+        hvf_state->hvf_caps = g_new0(struct hvf_vcpu_caps, 1);
+    }
     env->hvf_mmio_buf = g_new(char, 4096);
 
     if (x86cpu->vmware_cpuid_freq) {
-- 
2.39.3 (Apple Git-145)



  parent reply	other threads:[~2024-11-05 16:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-05 15:57 [PATCH 0/5] i386/hvf: x2apic support and some small fixes Phil Dennis-Jordan
2024-11-05 15:57 ` [PATCH 1/5] i386/hvf: Integrates x2APIC support with hvf accel Phil Dennis-Jordan
2024-11-06 10:44   ` Roman Bolshakov
2024-11-05 15:57 ` [PATCH 2/5] i386/hvf: Fix for UB in handling CPUID function 0xD Phil Dennis-Jordan
2024-11-06 14:01   ` Roman Bolshakov
2024-11-05 15:57 ` Phil Dennis-Jordan [this message]
2024-11-06 14:03   ` [PATCH 3/5] i386/hvf: Fixes startup memory leak (vmcs caps) Roman Bolshakov
2024-11-05 15:57 ` [PATCH 4/5] i386/hvf: Raise exception on error setting APICBASE Phil Dennis-Jordan
2024-11-06 14:04   ` Roman Bolshakov
2024-11-05 15:58 ` [PATCH 5/5] i386/hvf: Removes duplicate/shadowed variables in hvf_vcpu_exec Phil Dennis-Jordan
2024-11-06 14:05   ` Roman Bolshakov
2024-11-06 15:26 ` [PATCH 0/5] i386/hvf: x2apic support and some small fixes Roman Bolshakov
2024-11-06 18:45   ` Phil Dennis-Jordan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241105155800.5461-4-phil@philjordan.eu \
    --to=phil@philjordan.eu \
    --cc=dirty@apple.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rbolshakov@ddn.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).