All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Qiang <liq3ea@gmail.com>
To: jsnow@redhat.com, qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, ppandit@redhat.com, Li Qiang <liqiang6-s@360.cn>
Subject: [Qemu-devel] [PATCH 3/3] ide: ahci: call cleanup function in ahci unit
Date: Thu,  2 Mar 2017 02:08:13 -0800	[thread overview]
Message-ID: <1488449293-80280-4-git-send-email-liqiang6-s@360.cn> (raw)
In-Reply-To: <1488449293-80280-1-git-send-email-liqiang6-s@360.cn>

This can avoid memory leak when hotunplug the ahci device.

Signed-off-by: Li Qiang <liqiang6-s@360.cn>
---
 hw/ide/ahci.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index 6a17acf..f60826d 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -1485,6 +1485,18 @@ void ahci_realize(AHCIState *s, DeviceState *qdev, AddressSpace *as, int ports)
 
 void ahci_uninit(AHCIState *s)
 {
+    int i, j;
+
+    for (i = 0; i < s->ports; i++) {
+        AHCIDevice *ad = &s->dev[i];
+
+        for (j = 0; j < 2; j++) {
+            IDEState *s = &ad->port.ifs[j];
+
+            ide_exit(s);
+        }
+    }
+
     g_free(s->dev);
 }
 
-- 
1.8.3.1

  parent reply	other threads:[~2017-03-02 10:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-02 10:08 [Qemu-devel] [PATCH 0/3] ide: ahci: fix memory leak in device unit Li Qiang
2017-03-02 10:08 ` [Qemu-devel] [PATCH 1/3] ide: qdev: register ide bus unrealize function Li Qiang
2017-03-02 23:46   ` Philippe Mathieu-Daudé
2017-03-02 10:08 ` [Qemu-devel] [PATCH 2/3] ide: core: add cleanup function Li Qiang
2017-03-02 10:08 ` Li Qiang [this message]
2017-03-03 22:48 ` [Qemu-devel] [PATCH 0/3] ide: ahci: fix memory leak in device unit John Snow
2017-03-14  2:41   ` Li Qiang
2017-03-14 19:03     ` John Snow

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=1488449293-80280-4-git-send-email-liqiang6-s@360.cn \
    --to=liq3ea@gmail.com \
    --cc=jsnow@redhat.com \
    --cc=liqiang6-s@360.cn \
    --cc=pbonzini@redhat.com \
    --cc=ppandit@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.