]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
hw/virtio: Fix leak of host-notifier memory-region
authorYajun Wu <yajunw@nvidia.com>
Mon, 16 Aug 2021 01:32:35 +0000 (04:32 +0300)
committerMichael S. Tsirkin <mst@redhat.com>
Sat, 4 Sep 2021 13:07:45 +0000 (09:07 -0400)
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>
Message-Id: <1629077555-19907-1-git-send-email-yajunw@nvidia.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/virtio/vhost-user.c

index 2407836facafd5a8e3ca73b01cd54b7c8ee40282..33002300c26b5c7db88e1731ea2ca4e1feb8cb84 100644 (file)
@@ -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;
     }