[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 6/9] allow switching a qiov between internal and
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [RFC PATCH 6/9] allow switching a qiov between internal and external storage |
Date: |
Mon, 6 Jun 2011 18:26:57 +0200 |
qemu_iovec_reset and qemu_iovec_destroy will switch from external to
internal storage (it was previously forbidden to call it with external
storage). So, qemu_iovec_destroy followed by qemu_iovec_init_external
will not leak memory when called on a qiov that already had internal
storage allocated.
Signed-off-by: Paolo Bonzini <address@hidden>
---
cutils.c | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/cutils.c b/cutils.c
index f9a7e36..0fef64a 100644
--- a/cutils.c
+++ b/cutils.c
@@ -215,14 +215,22 @@ void qemu_iovec_concat(QEMUIOVector *dst, QEMUIOVector
*src, size_t size)
void qemu_iovec_destroy(QEMUIOVector *qiov)
{
- assert(qiov->nalloc != -1);
+ if (qiov->nalloc != -1) {
+ qemu_free(qiov->iov);
+ qiov->nalloc = 0;
+ qiov->iov = NULL;
+ }
- qemu_free(qiov->iov);
+ qiov->niov = 0;
+ qiov->size = 0;
}
void qemu_iovec_reset(QEMUIOVector *qiov)
{
- assert(qiov->nalloc != -1);
+ if (qiov->nalloc == -1) {
+ qiov->nalloc = 0;
+ qiov->iov = NULL;
+ }
qiov->niov = 0;
qiov->size = 0;
--
1.7.4.4
- [Qemu-devel] [RFC PATCH 0/9] scsi: support s/g operation without a bounce buffer, Paolo Bonzini, 2011/06/06
- [Qemu-devel] [RFC PATCH 1/9] make qbus_reset_all public, Paolo Bonzini, 2011/06/06
- [Qemu-devel] [RFC PATCH 3/9] pvscsi: check validity of DMA addresses in advance, Paolo Bonzini, 2011/06/06
- [Qemu-devel] [RFC PATCH 2/9] pvscsi: first commit, Paolo Bonzini, 2011/06/06
- [Qemu-devel] [RFC PATCH 5/9] scsi-disk: lazily allocate bounce buffer, Paolo Bonzini, 2011/06/06
- [Qemu-devel] [RFC PATCH 6/9] allow switching a qiov between internal and external storage,
Paolo Bonzini <=
- [Qemu-devel] [RFC PATCH 4/9] scsi: always use get_sense, Paolo Bonzini, 2011/06/06
- [Qemu-devel] [RFC PATCH 8/9] scsi: add get_iovec/unmap_iovec to SCSIBusOps, Paolo Bonzini, 2011/06/06
- [Qemu-devel] [RFC PATCH 7/9] scsi: push qiov to SCSIRequest, Paolo Bonzini, 2011/06/06
- [Qemu-devel] [RFC PATCH 9/9] pvscsi: implement s/g operation without a bounce buffer, Paolo Bonzini, 2011/06/06