[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 02/23] vhost: fix resource leak in error handling
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 02/23] vhost: fix resource leak in error handling |
Date: |
Mon, 23 Jun 2014 18:53:07 +0300 |
vhost_verify_ring_mappings leaks mappings on error.
Fix this up.
Cc: address@hidden
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
hw/virtio/vhost.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 84d382b..e55fe1c 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -305,7 +305,9 @@ static int vhost_verify_ring_mappings(struct vhost_dev *dev,
uint64_t size)
{
int i;
- for (i = 0; i < dev->nvqs; ++i) {
+ int r = 0;
+
+ for (i = 0; !r && i < dev->nvqs; ++i) {
struct vhost_virtqueue *vq = dev->vqs + i;
hwaddr l;
void *p;
@@ -317,15 +319,15 @@ static int vhost_verify_ring_mappings(struct vhost_dev
*dev,
p = cpu_physical_memory_map(vq->ring_phys, &l, 1);
if (!p || l != vq->ring_size) {
fprintf(stderr, "Unable to map ring buffer for ring %d\n", i);
- return -ENOMEM;
+ r = -ENOMEM;
}
if (p != vq->ring) {
fprintf(stderr, "Ring buffer relocated for ring %d\n", i);
- return -EBUSY;
+ r = -EBUSY;
}
cpu_physical_memory_unmap(p, l, 0, 0);
}
- return 0;
+ return r;
}
static struct vhost_memory_region *vhost_dev_find_reg(struct vhost_dev *dev,
--
MST
- [Qemu-devel] [PULL 00/23] pc,pci,vhost,net fixes, enhancements, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 01/23] vhost: block migration if backend does not log memory, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 02/23] vhost: fix resource leak in error handling,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 03/23] qapi/hmp: use 'backend' instead of 'device' with memory backend, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 04/23] libqemustub: add more stubs for qemu-char, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 05/23] qtest: fix qtest for vhost-user, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 06/23] qtest: fix vhost-user-test unbalanced mutex locks, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 08/23] e1000: improve auto-negotiation reporting via mii-tool, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 07/23] e1000: emulate auto-negotiation during external link status change, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 09/23] e1000: signal guest on successful link auto-negotiation, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 10/23] e1000: move e1000_autoneg_timer() to after set_ics(), Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 11/23] e1000: factor out checking for auto-negotiation availability, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 13/23] qemu-char: fix qemu_chr_fe_get_msgfd(), Michael S. Tsirkin, 2014/06/23