From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NZvRB-0000YI-Sm for qemu-devel@nongnu.org; Tue, 26 Jan 2010 19:07:13 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NZvR7-0000WX-Cn for qemu-devel@nongnu.org; Tue, 26 Jan 2010 19:07:13 -0500 Received: from [199.232.76.173] (port=60603 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZvR7-0000WR-0l for qemu-devel@nongnu.org; Tue, 26 Jan 2010 19:07:09 -0500 Received: from mail-iw0-f188.google.com ([209.85.223.188]:39899) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NZvR6-00063J-G8 for qemu-devel@nongnu.org; Tue, 26 Jan 2010 19:07:08 -0500 Received: by mail-iw0-f188.google.com with SMTP id 26so5513513iwn.14 for ; Tue, 26 Jan 2010 16:07:08 -0800 (PST) Message-ID: <4B5F83AA.5000408@codemonkey.ws> Date: Tue, 26 Jan 2010 18:07:06 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] win32: pair qemu_memalign() with qemu_vfree() References: <1264368236-3024-1-git-send-email-hpoussin@reactos.org> In-Reply-To: <1264368236-3024-1-git-send-email-hpoussin@reactos.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Herve Poussineau Cc: qemu-devel@nongnu.org On 01/24/2010 03:23 PM, Herve Poussineau wrote: > 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 > Applied. Thanks. Regards, Anthony Liguori > --- > block.c | 2 +- > block/raw-posix.c | 2 +- > exec.c | 2 +- > hw/scsi-disk.c | 2 +- > qemu-nbd.c | 2 +- > 5 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/block.c b/block.c > index 73c26ec..6e440b7 100644 > --- a/block.c > +++ b/block.c > @@ -1629,7 +1629,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 52bbcda..b4ff841 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); > } > } > > diff --git a/exec.c b/exec.c > index 1190591..76831a1 100644 > --- a/exec.c > +++ b/exec.c > @@ -3309,7 +3309,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 e3924de..b34fbaa 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 4463679..eac0c21 100644 > --- a/qemu-nbd.c > +++ b/qemu-nbd.c > @@ -469,7 +469,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); >