]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
ide: ahci: call cleanup function in ahci unit
authorLi Qiang <liq3ea@gmail.com>
Thu, 16 Mar 2017 00:50:14 +0000 (20:50 -0400)
committerJohn Snow <jsnow@redhat.com>
Thu, 16 Mar 2017 00:50:14 +0000 (20:50 -0400)
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>
hw/ide/ahci.c

index 6a17acf639a4b0bf8fe2de4dfabcdcdd86978ed0..f60826d6e0d4742d71adda1d13d2a8379f642cf1 100644 (file)
@@ -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);
 }