From: Li Qiang Date: Thu, 16 Mar 2017 00:50:14 +0000 (-0400) Subject: ide: ahci: call cleanup function in ahci unit X-Git-Tag: v2.9.0-rc1~22^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d68f0f778e7f4fbd674627274267f269e40f0b04;p=thirdparty%2Fqemu.git ide: ahci: call cleanup function in ahci unit This can avoid memory leak when hotunplug the ahci device. Signed-off-by: Li Qiang Message-id: 1488449293-80280-4-git-send-email-liqiang6-s@360.cn Signed-off-by: John Snow --- diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 6a17acf639a..f60826d6e0d 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); }