From: Pan Nengyuan <pannengyuan@huawei.com>
To: <qemu-devel@nongnu.org>
Cc: zhang.zhanghailiang@huawei.com, mst@redhat.com,
Pan Nengyuan <pannengyuan@huawei.com>,
Eric Auger <eric.auger@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
euler.robot@huawei.com
Subject: [PATCH v4 2/2] virtio-iommu: avoid memleak in the unrealize
Date: Sat, 28 Mar 2020 08:57:05 +0800 [thread overview]
Message-ID: <20200328005705.29898-3-pannengyuan@huawei.com> (raw)
In-Reply-To: <20200328005705.29898-1-pannengyuan@huawei.com>
req_vq/event_vq forgot to free in unrealize. Fix that.
And also do clean 's->as_by_busptr' hash table in unrealize to fix another leak.
Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
Acked-by: Eric Auger <eric.auger@redhat.com>
---
Cc: Eric Auger <eric.auger@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
---
v3->v1/v2:
- Also clean 's->as_by_busptr' hash table in unrealize.(Suggested by Stefano Garzarella)
v4->v3:
- update subject msg and move g_hash_table_destroy to the beginning of unrealize.
---
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..22ba8848c2 100644
--- a/hw/virtio/virtio-iommu.c
+++ b/hw/virtio/virtio-iommu.c
@@ -693,9 +693,12 @@ static void virtio_iommu_device_unrealize(DeviceState *dev, Error **errp)
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIOIOMMU *s = VIRTIO_IOMMU(dev);
+ g_hash_table_destroy(s->as_by_busptr);
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);
}
--
2.18.2
next prev parent reply other threads:[~2020-03-28 0:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-28 0:57 [PATCH v4 0/2] fix two virtio queues memleak Pan Nengyuan
2020-03-28 0:57 ` [PATCH v4 1/2] virtio-blk: delete vqs on the error path in realize() Pan Nengyuan
2020-03-30 8:59 ` Stefan Hajnoczi
2020-03-30 10:58 ` Pankaj Gupta
2020-03-28 0:57 ` Pan Nengyuan [this message]
2020-03-30 7:24 ` [PATCH v4 2/2] virtio-iommu: avoid memleak in the unrealize Stefano Garzarella
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=20200328005705.29898-3-pannengyuan@huawei.com \
--to=pannengyuan@huawei.com \
--cc=eric.auger@redhat.com \
--cc=euler.robot@huawei.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.