qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Subject: Re: [PATCH] hw/i386/amd_iommu: Don't leak memory in amdvi_update_iotlb()
Date: Wed, 31 Jul 2024 23:07:56 +0200	[thread overview]
Message-ID: <fe26dcae-7784-4285-89c2-ee27a1de7014@linaro.org> (raw)
In-Reply-To: <20240731170019.3590563-1-peter.maydell@linaro.org>

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	other threads:[~2024-07-31 21:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-31 17:00 [PATCH] hw/i386/amd_iommu: Don't leak memory in amdvi_update_iotlb() Peter Maydell
2024-07-31 21:07 ` Philippe Mathieu-Daudé [this message]
2025-02-17  7:26 ` Philippe Mathieu-Daudé
2025-02-20 15:55   ` Alejandro Jimenez

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=fe26dcae-7784-4285-89c2-ee27a1de7014@linaro.org \
    --to=philmd@linaro.org \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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).