aboutsummaryrefslogtreecommitdiff
path: root/hw/ide/ahci.c
diff options
context:
space:
mode:
authorLi Qiang <liq3ea@gmail.com>2017-03-15 20:50:14 -0400
committerJohn Snow <jsnow@redhat.com>2017-03-15 20:50:14 -0400
commitd68f0f778e7f4fbd674627274267f269e40f0b04 (patch)
treea2cd0735b396786bdb84ad7f56b9df220bc39b61 /hw/ide/ahci.c
parentc9f086418a255f386e1c4d2c1418c032eb349537 (diff)
downloadqemu-d68f0f778e7f4fbd674627274267f269e40f0b04.zip
qemu-d68f0f778e7f4fbd674627274267f269e40f0b04.tar.gz
qemu-d68f0f778e7f4fbd674627274267f269e40f0b04.tar.bz2
ide: ahci: call cleanup function in ahci unit
This can avoid memory leak when hotunplug the ahci device. Signed-off-by: Li Qiang <liqiang6-s@360.cn> Message-id: 1488449293-80280-4-git-send-email-liqiang6-s@360.cn Signed-off-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'hw/ide/ahci.c')
-rw-r--r--hw/ide/ahci.c12
1 files changed, 12 insertions, 0 deletions
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);
}