cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
dc1fe0
From 2005e3bb97fba4889829b58331a057b9cb35a65d Mon Sep 17 00:00:00 2001
dc1fe0
From: Laurent Vivier <lvivier@redhat.com>
dc1fe0
Date: Fri, 11 Feb 2022 18:02:59 +0100
dc1fe0
Subject: [PATCH 2/5] hw/virtio: vdpa: Fix leak of host-notifier memory-region
dc1fe0
dc1fe0
RH-Author: Laurent Vivier <lvivier@redhat.com>
dc1fe0
RH-MergeRequest: 123: hw/virtio: vdpa: Fix leak of host-notifier memory-region
dc1fe0
RH-Commit: [1/1] ddd64cac5c29786edf652f5fa97767b261ccfcdd
dc1fe0
RH-Bugzilla: 2059786
dc1fe0
RH-Acked-by: Jason Wang <jasowang@redhat.com>
dc1fe0
RH-Acked-by: Cindy Lu <lulu@redhat.com>
dc1fe0
RH-Acked-by: MST <mst@redhat.com>
dc1fe0
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
dc1fe0
dc1fe0
BZ: https://bugzilla.redhat.com/2059786
dc1fe0
BRANCH: rhel-9.0.0
dc1fe0
BREW: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=43688388
dc1fe0
UPTREAM: Merged
dc1fe0
dc1fe0
If call virtio_queue_set_host_notifier_mr fails, should free
dc1fe0
host-notifier memory-region.
dc1fe0
dc1fe0
This problem can trigger a coredump with some vDPA drivers (mlx5,
dc1fe0
but not with the vdpasim), if we unplug the virtio-net card from
dc1fe0
the guest after a stop/start.
dc1fe0
dc1fe0
The same fix has been done for vhost-user:
dc1fe0
  1f89d3b91e3e ("hw/virtio: Fix leak of host-notifier memory-region")
dc1fe0
dc1fe0
Fixes: d0416d487bd5 ("vhost-vdpa: map virtqueue notification area if possible")
dc1fe0
Cc: jasowang@redhat.com
dc1fe0
Resolves: https://bugzilla.redhat.com/2027208
dc1fe0
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
dc1fe0
Message-Id: <20220211170259.1388734-1-lvivier@redhat.com>
dc1fe0
Cc: qemu-stable@nongnu.org
dc1fe0
Acked-by: Jason Wang <jasowang@redhat.com>
dc1fe0
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
dc1fe0
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
dc1fe0
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
dc1fe0
(cherry picked from commit 98f7607ecda00dea3cbb2ed7b4427c96846efb83)
dc1fe0
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
dc1fe0
---
dc1fe0
 hw/virtio/vhost-vdpa.c | 1 +
dc1fe0
 1 file changed, 1 insertion(+)
dc1fe0
dc1fe0
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
dc1fe0
index bcaf00e09f..78da48a333 100644
dc1fe0
--- a/hw/virtio/vhost-vdpa.c
dc1fe0
+++ b/hw/virtio/vhost-vdpa.c
dc1fe0
@@ -415,6 +415,7 @@ static int vhost_vdpa_host_notifier_init(struct vhost_dev *dev, int queue_index)
dc1fe0
     g_free(name);
dc1fe0
 
dc1fe0
     if (virtio_queue_set_host_notifier_mr(vdev, queue_index, &n->mr, true)) {
dc1fe0
+        object_unparent(OBJECT(&n->mr));
dc1fe0
         munmap(addr, page_size);
dc1fe0
         goto err;
dc1fe0
     }
dc1fe0
-- 
dc1fe0
2.31.1
dc1fe0