[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 078/108] vhost: fix resource leak in error handling
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 078/108] vhost: fix resource leak in error handling |
Date: |
Wed, 6 Aug 2014 15:39:28 -0500 |
From: "Michael S. Tsirkin" <address@hidden>
vhost_verify_ring_mappings leaks mappings on error.
Fix this up.
Cc: address@hidden
Signed-off-by: Michael S. Tsirkin <address@hidden>
(cherry picked from commit 8617343faae6ba7e916137c6c9e3ef22c00565d8)
Signed-off-by: Michael Roth <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 9e336ad..1d349e0 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -309,7 +309,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;
@@ -321,15 +323,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,
--
1.9.1
- [Qemu-devel] [PATCH 034/108] qdev: Fix crash by validating the object type, (continued)
- [Qemu-devel] [PATCH 034/108] qdev: Fix crash by validating the object type, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 067/108] s390x/css: handle emw correctly for tsch, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 068/108] aio: fix qemu_bh_schedule() bh->ctx race condition, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 070/108] migration: remove duplicate code, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 069/108] qga: Fix handle fd leak in acquire_privilege(), Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 071/108] arch_init: Be sure of only one exit entry with DPRINTF() for ram_load(), Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 072/108] migration: catch unknown flags in ram_load, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 073/108] rdma: bug fixes, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 075/108] qdev: reorganize error reporting in bus_set_realized, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 076/108] qdev: recursively unrealize devices when unrealizing bus, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 078/108] vhost: fix resource leak in error handling,
Michael Roth <=
- [Qemu-devel] [PATCH 077/108] scsi-disk: fix bug in scsi_block_new_request() introduced by commit 137745c, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 079/108] virtio-scsi: define dummy handle_output for vhost-scsi vqs, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 080/108] usb: Fix usb-bt-dongle initialization., Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 083/108] coroutine-win32.c: Add noinline attribute to work around gcc bug, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 086/108] target-i386: Filter FEAT_7_0_EBX TCG features too, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 082/108] q35: Use PC_Q35_COMPAT_1_4 on pc-q35-1.4 compat_props, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 084/108] hw/xtensa/xtfpga: fix FLASH mapping to boot region for KC705, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 085/108] target-i386: Make TCG feature filtering more readable, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 088/108] virtio-serial: don't migrate the config space, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 087/108] virtio-net: byteswap virtio-net header, Michael Roth, 2014/08/06