Skip to contentSkip to conversation

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

PATCH Superseded Yajun Wu via 2 participants 2 messages Aug 12, 2021

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/virtio: Fix leak of host-notifier memory-region

If call virtio_queue_set_host_notifier_mr fails, should free host-notifier memory-region.

---
 hw/virtio/vhost-user.c | 1 +
 1 file changed, 1 insertion(+)
hw/virtio/vhost-user.c +1 -0
index aec6cc1..3ae5297 100644
@@ -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;
     }
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Yajun Wu via

If call virtio_queue_set_host_notifier_mr fails, should free host-notifier memory-region.

We can add:

Fixes 44866521bd ("vhost-user: support registering external host notifiers")
Quoted 21 lines

---
hw/virtio/vhost-user.c | 1 +

1 file changed, 1 insertion(+)
hw/virtio/vhost-user.c +1 -0
index aec6cc1..3ae5297 100644
@@ -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;
    }
Signature · 1 line
1.8.3.1