qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] hw/i386/amd_iommu: Don't leak memory in amdvi_update_iotlb()


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH] hw/i386/amd_iommu: Don't leak memory in amdvi_update_iotlb()
Date: Wed, 31 Jul 2024 23:07:56 +0200
User-agent: Mozilla Thunderbird

On 31/7/24 19:00, Peter Maydell wrote:
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>
---
Tested with 'make check' and 'make check-avocado' only, but the
bug and fix seem straightforward...
---
  hw/i386/amd_iommu.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]