From: Stefano Garzarella <sgarzare@redhat.com>
To: Pan Nengyuan <pannengyuan@huawei.com>
Cc: Eric Auger <eric.auger@redhat.com>,
zhang.zhanghailiang@huawei.com, mst@redhat.com,
qemu-devel@nongnu.org, euler.robot@huawei.com
Subject: Re: [PATCH v3 2/2] virtio-iommu: delete vqs in unrealize to fix memleak
Date: Fri, 27 Mar 2020 17:26:12 +0100 [thread overview]
Message-ID: <20200327162612.ic2ymmpfvyt5xbnp@steredhat> (raw)
In-Reply-To: <20200327095642.18424-3-pannengyuan@huawei.com>
On Fri, Mar 27, 2020 at 05:56:42PM +0800, Pan Nengyuan wrote:
> req_vq/event_vq forgot to free in unrealize. Fix that.
> And aslo do clean 's->as_by_busptr' hash table in unrealize to fix another leak.
s/aslo/also
Maybe we can also update the subject in something like this:
"virtio-iommu: avoid memleak in the unrealize"
>
> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
> Acked-by: Eric Auger <eric.auger@redhat.com>
> ---
> Cc: Eric Auger <eric.auger@redhat.com>
> ---
> v3->v1/v2:
> - Aslo clean 's->as_by_busptr' hash table in unrealize.(Suggested by Stefano Garzarella)
> ---
> hw/virtio/virtio-iommu.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
> index 4cee8083bc..694698fa0f 100644
> --- a/hw/virtio/virtio-iommu.c
> +++ b/hw/virtio/virtio-iommu.c
> @@ -696,7 +696,10 @@ static void virtio_iommu_device_unrealize(DeviceState *dev, Error **errp)
> g_tree_destroy(s->domains);
> g_tree_destroy(s->endpoints);
>
> + virtio_delete_queue(s->req_vq);
> + virtio_delete_queue(s->event_vq);
> virtio_cleanup(vdev);
> + g_hash_table_destroy(s->as_by_busptr);
If you need to respin, you could move g_hash_table_destroy()
at the beggining of unrealize(), just to follow a reverse order of
realize().
Thanks,
Stefano
> }
>
> static void virtio_iommu_device_reset(VirtIODevice *vdev)
> --
> 2.18.2
>
>
next prev parent reply other threads:[~2020-03-27 16:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-27 9:56 [PATCH v3 0/2] fix two virtio queues memleak Pan Nengyuan
2020-03-27 9:56 ` [PATCH v3 1/2] virtio-blk: delete vqs on the error path in realize() Pan Nengyuan
2020-03-27 9:56 ` [PATCH v3 2/2] virtio-iommu: delete vqs in unrealize to fix memleak Pan Nengyuan
2020-03-27 16:26 ` Stefano Garzarella [this message]
2020-03-28 0:31 ` Pan Nengyuan
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=20200327162612.ic2ymmpfvyt5xbnp@steredhat \
--to=sgarzare@redhat.com \
--cc=eric.auger@redhat.com \
--cc=euler.robot@huawei.com \
--cc=mst@redhat.com \
--cc=pannengyuan@huawei.com \
--cc=qemu-devel@nongnu.org \
--cc=zhang.zhanghailiang@huawei.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).