qemu-kvm/kvm-hw-virtio-vdpa-Fix-leak...

61 lines
2.3 KiB
Diff

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