]> git.ipfire.org Git - thirdparty/qemu.git/commit
hw/i386/amd_iommu: Don't leak memory in amdvi_update_iotlb()
authorPeter Maydell <peter.maydell@linaro.org>
Wed, 31 Jul 2024 17:00:19 +0000 (18:00 +0100)
committerMichael Tokarev <mjt@tls.msk.ru>
Fri, 2 Aug 2024 07:35:37 +0000 (10:35 +0300)
commit41e0ca8bc8e98fcb631baf6d22a9045baceb14b2
treef2cfe07d89447dad0cd6409b54eb87f13547a6cb
parent701202a5a4b32d7e856590affc721fb396a02e86
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 9a45b0761628cc59267b3283a85d15294464ac31)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
hw/i386/amd_iommu.c