diff options
author | Herve Poussineau <hpoussin@reactos.org> | 2010-01-24 21:23:56 +0000 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2010-01-26 18:09:22 -0600 |
commit | a1a86bf902f4359d1556fb37a5443024b42898f4 (patch) | |
tree | dd755cc440c9eebebbed284badfe56d50365256e | |
parent | c727a054594b1c94177373680408fbf4ee92d3f1 (diff) |
win32: pair qemu_memalign() with qemu_vfree()
Win32 suffers from a very big memory leak when dealing with SCSI devices.
Each read/write request allocates memory with qemu_memalign (ie
VirtualAlloc) but frees it with qemu_free (ie free).
Pair all qemu_memalign() calls with qemu_vfree() to prevent such leaks.
Signed-off-by: Herve Poussineau <hpoussin@reactos.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit f8a83245d9ec685bc6aa6173d6765fe03e20688f)
-rw-r--r-- | block.c | 2 | ||||
-rw-r--r-- | block/raw-posix.c | 2 | ||||
-rw-r--r-- | exec.c | 2 | ||||
-rw-r--r-- | hw/scsi-disk.c | 2 | ||||
-rw-r--r-- | qemu-nbd.c | 2 |
5 files changed, 5 insertions, 5 deletions
@@ -1607,7 +1607,7 @@ static void multiwrite_user_cb(MultiwriteCB *mcb) for (i = 0; i < mcb->num_callbacks; i++) { mcb->callbacks[i].cb(mcb->callbacks[i].opaque, mcb->error); qemu_free(mcb->callbacks[i].free_qiov); - qemu_free(mcb->callbacks[i].free_buf); + qemu_vfree(mcb->callbacks[i].free_buf); } } diff --git a/block/raw-posix.c b/block/raw-posix.c index 5a6a22bee6..248e34cbad 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -595,7 +595,7 @@ static void raw_close(BlockDriverState *bs) close(s->fd); s->fd = -1; if (s->aligned_buf != NULL) - qemu_free(s->aligned_buf); + qemu_vfree(s->aligned_buf); } } @@ -3307,7 +3307,7 @@ void cpu_physical_memory_unmap(void *buffer, target_phys_addr_t len, if (is_write) { cpu_physical_memory_write(bounce.addr, bounce.buffer, access_len); } - qemu_free(bounce.buffer); + qemu_vfree(bounce.buffer); bounce.buffer = NULL; cpu_notify_map_clients(); } diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index e3924dec9d..b34fbaa674 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -81,7 +81,7 @@ static SCSIDiskReq *scsi_new_request(SCSIDevice *d, uint32_t tag, uint32_t lun) static void scsi_remove_request(SCSIDiskReq *r) { - qemu_free(r->iov.iov_base); + qemu_vfree(r->iov.iov_base); scsi_req_free(&r->req); } diff --git a/qemu-nbd.c b/qemu-nbd.c index 6cdb83473f..4ea8c9e45c 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -467,7 +467,7 @@ int main(int argc, char **argv) } } } while (persistent || nb_fds > 1); - qemu_free(data); + qemu_vfree(data); close(sharing_fds[0]); bdrv_close(bs); |