From: Yajun Wu Date: Mon, 16 Aug 2021 01:32:35 +0000 (+0300) Subject: hw/virtio: Fix leak of host-notifier memory-region X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=1f89d3b91e3e222e468d98057f5eaf8ebac0e7bf;p=qemu.git hw/virtio: Fix leak of host-notifier memory-region 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 Message-Id: <1629077555-19907-1-git-send-email-yajunw@nvidia.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 2407836fac..33002300c2 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; }