aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2011-11-25 12:06:22 +0100
committerJustin M. Forbes <jforbes@redhat.com>2012-01-10 13:36:27 -0600
commit6061f16a8a119a46e61f2ddbabdb58f83e8857f7 (patch)
treeb053b6fdb0260d75bd00ebb7cf67a0cdec3160de
parent23201c64a789cf948fedcea221a4b6e197fcd628 (diff)
qiov: prevent double free or use-after-free
qemu_iovec_destroy does not clear the QEMUIOVector fully, and the data could thus be used after free or freed again. While I do not know any example in the tree, I observed this using virtio-scsi (and SCSI scatter/gather) when canceling DMA requests. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r--cutils.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/cutils.c b/cutils.c
index 6db6304bb..24b3fe355 100644
--- a/cutils.c
+++ b/cutils.c
@@ -217,7 +217,10 @@ void qemu_iovec_destroy(QEMUIOVector *qiov)
{
assert(qiov->nalloc != -1);
+ qemu_iovec_reset(qiov);
g_free(qiov->iov);
+ qiov->nalloc = 0;
+ qiov->iov = NULL;
}
void qemu_iovec_reset(QEMUIOVector *qiov)