qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PULL for-rc1 3/3] ide: ahci: call cleanup function in ahci


From: John Snow
Subject: [Qemu-devel] [PULL for-rc1 3/3] ide: ahci: call cleanup function in ahci unit
Date: Wed, 15 Mar 2017 20:52:59 -0400

From: Li Qiang <address@hidden>

This can avoid memory leak when hotunplug the ahci device.

Signed-off-by: Li Qiang <address@hidden>
Message-id: address@hidden
Signed-off-by: John Snow <address@hidden>
---
 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);
 }
 
-- 
2.9.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]