summary refs log tree commit diff stats
path: root/hw/vfio/common.c
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2021-11-18 09:39:47 +0100
committerRichard Henderson <richard.henderson@linaro.org>2021-11-18 09:39:47 +0100
commit0055ecca84cb948c935224b4f7ca1ceb26209790 (patch)
tree5cb488903ab08148ca94ce3b32d0caf43a36309f /hw/vfio/common.c
parent3bb87484e77d22cf4e580a78856529c982195d32 (diff)
parentf3bc3a73c908df15966e66f88d5a633bd42fd029 (diff)
downloadfocaccia-qemu-0055ecca84cb948c935224b4f7ca1ceb26209790.tar.gz
focaccia-qemu-0055ecca84cb948c935224b4f7ca1ceb26209790.zip
Merge tag 'vfio-fixes-20211117.0' of git://github.com/awilliam/qemu-vfio into staging
VFIO fixes 2021-11-17

 * Fix hostwin memory leak (Peng Liang)

# gpg: Signature made Wed 17 Nov 2021 08:05:09 PM CET
# gpg:                using RSA key 42F6C04E540BD1A99E7B8A90239B9B6E3BB08B22
# gpg:                issuer "alex.williamson@redhat.com"
# gpg: Good signature from "Alex Williamson <alex.williamson@redhat.com>" [full]
# gpg:                 aka "Alex Williamson <alex@shazbot.org>" [full]
# gpg:                 aka "Alex Williamson <alwillia@redhat.com>" [full]
# gpg:                 aka "Alex Williamson <alex.l.williamson@gmail.com>" [full]

* tag 'vfio-fixes-20211117.0' of git://github.com/awilliam/qemu-vfio:
  vfio: Fix memory leak of hostwin

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'hw/vfio/common.c')
-rw-r--r--hw/vfio/common.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index dd387b0d39..080046e3f5 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -551,6 +551,7 @@ static int vfio_host_win_del(VFIOContainer *container, hwaddr min_iova,
     QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) {
         if (hostwin->min_iova == min_iova && hostwin->max_iova == max_iova) {
             QLIST_REMOVE(hostwin, hostwin_next);
+            g_free(hostwin);
             return 0;
         }
     }
@@ -2239,6 +2240,7 @@ static void vfio_disconnect_container(VFIOGroup *group)
     if (QLIST_EMPTY(&container->group_list)) {
         VFIOAddressSpace *space = container->space;
         VFIOGuestIOMMU *giommu, *tmp;
+        VFIOHostDMAWindow *hostwin, *next;
 
         QLIST_REMOVE(container, next);
 
@@ -2249,6 +2251,12 @@ static void vfio_disconnect_container(VFIOGroup *group)
             g_free(giommu);
         }
 
+        QLIST_FOREACH_SAFE(hostwin, &container->hostwin_list, hostwin_next,
+                           next) {
+            QLIST_REMOVE(hostwin, hostwin_next);
+            g_free(hostwin);
+        }
+
         trace_vfio_disconnect_container(container->fd);
         close(container->fd);
         g_free(container);