diff mbox series

[v2] hw/virtio: Fix leak of host-notifier memory-region

Message ID 1629077555-19907-1-git-send-email-yajunw@nvidia.com (mailing list archive)
State New, archived
Headers show
Series [v2] hw/virtio: Fix leak of host-notifier memory-region | expand

Commit Message

Yajun Wu Aug. 16, 2021, 1:32 a.m. UTC
If call virtio_queue_set_host_notifier_mr fails, should free
host-notifier memory-region.

Fixes: 44866521bd ("vhost-user: support registering external host notifiers")
Signed-off-by: Yajun Wu <yajunw@nvidia.com>
---
 hw/virtio/vhost-user.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index aec6cc1..3ae5297 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -1474,6 +1474,7 @@  static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *dev,
     g_free(name);
 
     if (virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, true)) {
+        object_unparent(OBJECT(&n->mr));
         munmap(addr, page_size);
         return -1;
     }