From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
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 [thread overview]
Message-ID: <1307377620-7538-7-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1307377620-7538-1-git-send-email-pbonzini@redhat.com>
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 <pbonzini@redhat.com>
---
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
next prev parent reply other threads:[~2011-06-06 16:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-06 16:26 [Qemu-devel] [RFC PATCH 0/9] scsi: support s/g operation without a bounce buffer Paolo Bonzini
2011-06-06 16:26 ` [Qemu-devel] [RFC PATCH 1/9] make qbus_reset_all public Paolo Bonzini
2011-06-06 16:26 ` [Qemu-devel] [RFC PATCH 2/9] pvscsi: first commit Paolo Bonzini
2011-06-06 16:26 ` [Qemu-devel] [RFC PATCH 3/9] pvscsi: check validity of DMA addresses in advance Paolo Bonzini
2011-06-06 16:26 ` [Qemu-devel] [RFC PATCH 4/9] scsi: always use get_sense Paolo Bonzini
2011-06-06 16:26 ` [Qemu-devel] [RFC PATCH 5/9] scsi-disk: lazily allocate bounce buffer Paolo Bonzini
2011-06-06 16:26 ` Paolo Bonzini [this message]
2011-06-06 16:26 ` [Qemu-devel] [RFC PATCH 7/9] scsi: push qiov to SCSIRequest Paolo Bonzini
2011-06-06 16:26 ` [Qemu-devel] [RFC PATCH 8/9] scsi: add get_iovec/unmap_iovec to SCSIBusOps Paolo Bonzini
2011-06-06 16:27 ` [Qemu-devel] [RFC PATCH 9/9] pvscsi: implement s/g operation without a bounce buffer Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1307377620-7538-7-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).