qemu/hw/i386
Peter Maydell c15edb498d hw/i386/amd_iommu: Don't leak memory in amdvi_update_iotlb()
In amdvi_update_iotlb() we will only put a new entry in the hash
table if to_cache.perm is not IOMMU_NONE.  However we allocate the
memory for the new AMDVIIOTLBEntry and for the hash table key
regardless.  This means that in the IOMMU_NONE case we will leak the
memory we alloacted.

Move the allocations into the if() to the point where we know we're
going to add the item to the hash table.

Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2452
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20240731170019.3590563-1-peter.maydell@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 9a45b07616)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2024-08-28 08:37:28 +03:00
..
kvm hw/xen_evtchn: Initialize flush_kvm_routes 2024-04-02 16:15:07 +02:00
xen hw/xen/hvm: Get target page size at runtime 2024-03-09 18:51:45 +01:00
acpi-build.c hw/i386/acpi-build: Add support for SRAT Generic Initiator structures 2024-03-12 17:56:55 -04:00
acpi-build.h hw/acpi/ich9: Enable ACPI PCI hot-plug 2021-07-16 04:33:35 -04:00
acpi-common.c Misc HW patch queue 2024-02-22 15:44:29 +00:00
acpi-common.h hw/i386/acpi: Declare pc_madt_cpu_entry() in 'acpi-common.h' 2024-02-20 20:34:21 +03:00
acpi-microvm.c hw/i386/acpi-microvm.c: Use common function to add virtio in DSDT 2024-01-10 18:47:46 +10:00
acpi-microvm.h microvm/acpi: add minimal acpi support 2020-09-17 14:16:19 +02:00
amd_iommu-stub.c amd_iommu: report x2APIC support to the operating system 2024-02-14 06:09:32 -05:00
amd_iommu.c hw/i386/amd_iommu: Don't leak memory in amdvi_update_iotlb() 2024-08-28 08:37:28 +03:00
amd_iommu.h amd_iommu: report x2APIC support to the operating system 2024-02-14 06:09:32 -05:00
e820_memory_layout.c hw/i386/e820: remove legacy reserved entries for e820 2022-11-02 06:56:31 -04:00
e820_memory_layout.h hw/i386/e820: remove legacy reserved entries for e820 2022-11-02 06:56:31 -04:00
fw_cfg.c smbios: get rid of global smbios_ep_type 2024-03-18 08:42:45 -04:00
fw_cfg.h smbios: get rid of global smbios_ep_type 2024-03-18 08:42:45 -04:00
intel_iommu_internal.h intel_iommu: fix FRCD construction macro 2024-07-24 07:41:28 +03:00
intel_iommu.c hw/i386/pc: Rename "bus" attribute to "pcibus" 2024-02-27 09:37:30 +01:00
Kconfig smbios: build legacy mode code only for 'pc' machine 2024-03-18 08:42:45 -04:00
meson.build hw/i386: Rename kvmvapic.c -> vapic.c 2024-03-09 18:51:45 +01:00
microvm-dt.c hw/rtc/mc146818rtc: QOM'ify io_base offset 2022-06-11 11:44:50 +02:00
microvm-dt.h microvm: add device tree support. 2021-11-02 17:24:17 +01:00
microvm.c hw/i386/x86: Let ioapic_init_gsi() take parent as pointer 2024-02-27 09:37:30 +01:00
multiboot.c bulk: Rename TARGET_FMT_plx -> HWADDR_FMT_plx 2023-01-18 11:14:34 +01:00
multiboot.h target/i386: use DMA-enabled multiboot ROM for new-enough QEMU machine types 2021-11-02 15:57:27 +01:00
pc_piix.c pc/q35: set SMBIOS entry point type to 'auto' by default 2024-03-18 08:42:46 -04:00
pc_q35.c pc_q35: remove unnecessary m->alias assignment 2024-04-02 18:08:59 +02:00
pc_sysfw_ovmf-stubs.c hw/i386: Introduce X86_FW_OVMF Kconfig symbol 2021-07-14 22:28:58 +02:00
pc_sysfw_ovmf.c hw/i386: Replace magic number with field length calculation 2022-03-06 05:08:23 -05:00
pc_sysfw.c Revert "hw/i386/pc: Confine system flash handling to pc_sysfw" 2024-03-12 17:56:55 -04:00
pc.c hw/i386/pc: Restrict CXL to PCI-based machines 2024-04-02 14:55:32 +02:00
port92.c hw/i386/port92: Add missing 'hw/isa/isa.h' header 2024-02-20 20:34:21 +03:00
sgx-epc.c Mark remaining global TypeInfo instances as const 2022-02-21 13:30:20 +00:00
sgx-stub.c target/i386: the sgx_epc_get_section stub is reachable 2023-12-31 09:11:27 +01:00
sgx.c target/i386: do not crash if microvm guest uses SGX CPUID leaves 2024-07-24 07:45:34 +03:00
trace-events vmmouse: replace DPRINTF with tracing 2023-09-12 10:37:01 +04:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
vapic.c hw/i386: Rename kvmvapic.c -> vapic.c 2024-03-09 18:51:45 +01:00
vmmouse.c hw/i386: Constify VMState 2023-12-29 11:17:30 +11:00
vmport.c Do not include cpu.h if it's not really necessary 2021-05-02 17:24:51 +02:00
x86-iommu-stub.c hw/i386/pc: Remove x86_iommu_get_type() 2021-11-01 18:49:10 -04:00
x86-iommu.c hw/i386/pc: Rename "bus" attribute to "pcibus" 2024-02-27 09:37:30 +01:00
x86.c hw/core: Declare CPUArchId::cpu as CPUState instead of Object 2024-03-12 11:46:16 +01:00