[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 03/11] ahci: Fix sglist memleak in ahci_dma_rw_buf()
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 03/11] ahci: Fix sglist memleak in ahci_dma_rw_buf() |
Date: |
Fri, 10 Aug 2012 18:47:21 +0200 |
From: Jason Baron <address@hidden>
I noticed that in hw/ide/ahci:ahci_dma_rw_buf() we do not free the sglist. Thus,
I've added a call to qemu_sglist_destroy() to fix this memory leak.
In addition, I've adeed a call in qemu_sglist_destroy() to 0 all of the sglist
fields, in case there is some other codepath that tries to free the sglist.
Signed-off-by: Jason Baron <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
dma-helpers.c | 1 +
hw/ide/ahci.c | 3 +++
2 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/dma-helpers.c b/dma-helpers.c
index 35cb500..13593d1 100644
--- a/dma-helpers.c
+++ b/dma-helpers.c
@@ -65,6 +65,7 @@ void qemu_sglist_add(QEMUSGList *qsg, dma_addr_t base,
dma_addr_t len)
void qemu_sglist_destroy(QEMUSGList *qsg)
{
g_free(qsg->sg);
+ memset(qsg, 0, sizeof(*qsg));
}
typedef struct {
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index de580a6..5ea3cad 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -1073,6 +1073,9 @@ static int ahci_dma_rw_buf(IDEDMA *dma, int is_write)
dma_buf_write(p, l, &s->sg);
}
+ /* free sglist that was created in ahci_populate_sglist() */
+ qemu_sglist_destroy(&s->sg);
+
/* update number of transferred bytes */
ad->cur_cmd->status = cpu_to_le32(le32_to_cpu(ad->cur_cmd->status) + l);
s->io_buffer_index += l;
--
1.7.6.5
- [Qemu-devel] [PULL 00/11] Block patches, Kevin Wolf, 2012/08/10
- [Qemu-devel] [PATCH 01/11] virtio-blk: fix use-after-free while handling scsi commands, Kevin Wolf, 2012/08/10
- [Qemu-devel] [PATCH 02/11] ahci: Fix ahci cdrom read corruptions for reads > 128k, Kevin Wolf, 2012/08/10
- [Qemu-devel] [PATCH 03/11] ahci: Fix sglist memleak in ahci_dma_rw_buf(),
Kevin Wolf <=
- [Qemu-devel] [PATCH 05/11] virtio-blk: support VIRTIO_BLK_F_CONFIG_WCE, Kevin Wolf, 2012/08/10
- [Qemu-devel] [PATCH 04/11] qemu-iotests: Save some sed processes, Kevin Wolf, 2012/08/10
- [Qemu-devel] [PATCH 06/11] virtio-blk: disable write cache if not negotiated, Kevin Wolf, 2012/08/10
- [Qemu-devel] [PATCH 09/11] qcow2: mark image clean after repair succeeds, Kevin Wolf, 2012/08/10
- [Qemu-devel] [PATCH 07/11] blockdev: flip default cache mode from writethrough to writeback, Kevin Wolf, 2012/08/10
- [Qemu-devel] [PATCH 08/11] qed: mark image clean after repair succeeds, Kevin Wolf, 2012/08/10
- [Qemu-devel] [PATCH 11/11] qemu-iotests: skip 039 with ./check -nocache, Kevin Wolf, 2012/08/10
- [Qemu-devel] [PATCH 10/11] block: add BLOCK_O_CHECK for qemu-img check, Kevin Wolf, 2012/08/10
- Re: [Qemu-devel] [PULL 00/11] Block patches, Anthony Liguori, 2012/08/12