qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Baron <jbaron@redhat.com>
To: agraf@suse.de
Cc: kwolf@redhat.com, aliguori@us.ibm.com, armbru@redhat.com,
	qemu-devel@nongnu.org, alex.williamson@redhat.com,
	avi@redhat.com, pbonzini@redhat.com
Subject: [Qemu-devel] [PATCH 2/2] ahci: Fix sglist memleak in ahci_dma_rw_buf()
Date: Thu, 26 Jul 2012 15:40:09 -0400	[thread overview]
Message-ID: <bcc22e1608bee5bea31d03ac855257301bd40dcc.1343330684.git.jbaron@redhat.com> (raw)
In-Reply-To: <cover.1343330684.git.jbaron@redhat.com>

I noticed that in hw/ide/ahci:ahci_dma_rw_buf() does not appear to free the
sglist. Thus, I've added a call to qemu_sglist_destroy() to fix this memory
leak.

I'm wondering though if 'ahci_populate_sglist()' can return 0, and not
populate the sglist, thus causing us to call free on NULL pointer. However, I
see that ahci_start_transfer() always calls the free if the return is 0.

Signed-off-by: Jason Baron <jbaron@redhat.com>
---
 hw/ide/ahci.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index 9c95714..b48401d 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.1

  parent reply	other threads:[~2012-07-26 19:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-26 19:40 [Qemu-devel] [PATCH 0/2] ahci: fix cdrom read corruption Jason Baron
2012-07-26 19:40 ` [Qemu-devel] [PATCH 1/2] ahci: Fix ahci cdrom read corruptions for reads > 128k Jason Baron
2012-07-27  7:59   ` Kevin Wolf
2012-07-27 14:50     ` Jason Baron
2012-07-27 11:28   ` Andreas Färber
2012-07-26 19:40 ` Jason Baron [this message]
2012-07-27  7:16   ` [Qemu-devel] [PATCH 2/2] ahci: Fix sglist memleak in ahci_dma_rw_buf() 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=bcc22e1608bee5bea31d03ac855257301bd40dcc.1343330684.git.jbaron@redhat.com \
    --to=jbaron@redhat.com \
    --cc=agraf@suse.de \
    --cc=alex.williamson@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=armbru@redhat.com \
    --cc=avi@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=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).