d4d9bf0
From 12351a91da97b414eec8cdb09f1d9f41e535a401 Mon Sep 17 00:00:00 2001
d4d9bf0
From: Li Qiang <liqiang6-s@360.cn>
d4d9bf0
Date: Wed, 14 Dec 2016 18:30:21 -0800
d4d9bf0
Subject: [PATCH] audio: ac97: add exit function
d4d9bf0
MIME-Version: 1.0
d4d9bf0
Content-Type: text/plain; charset=utf8
d4d9bf0
Content-Transfer-Encoding: 8bit
d4d9bf0
d4d9bf0
Currently the ac97 device emulation doesn't have a exit function,
d4d9bf0
hot unplug this device will leak some memory. Add a exit function to
d4d9bf0
avoid this.
d4d9bf0
d4d9bf0
Signed-off-by: Li Qiang <liqiang6-s@360.cn>
d4d9bf0
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
d4d9bf0
Message-id: 58520052.4825ed0a.27a71.6cae@mx.google.com
d4d9bf0
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
d4d9bf0
---
d4d9bf0
 hw/audio/ac97.c |   11 +++++++++++
d4d9bf0
 1 files changed, 11 insertions(+), 0 deletions(-)
d4d9bf0
d4d9bf0
diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c
d4d9bf0
index cbd959e..c306575 100644
d4d9bf0
--- a/hw/audio/ac97.c
d4d9bf0
+++ b/hw/audio/ac97.c
d4d9bf0
@@ -1387,6 +1387,16 @@ static void ac97_realize(PCIDevice *dev, Error **errp)
d4d9bf0
     ac97_on_reset (&s->dev.qdev);
d4d9bf0
 }
d4d9bf0
 
d4d9bf0
+static void ac97_exit(PCIDevice *dev)
d4d9bf0
+{
d4d9bf0
+    AC97LinkState *s = DO_UPCAST(AC97LinkState, dev, dev);
d4d9bf0
+
d4d9bf0
+    AUD_close_in(&s->card, s->voice_pi);
d4d9bf0
+    AUD_close_out(&s->card, s->voice_po);
d4d9bf0
+    AUD_close_in(&s->card, s->voice_mc);
d4d9bf0
+    AUD_remove_card(&s->card);
d4d9bf0
+}
d4d9bf0
+
d4d9bf0
 static int ac97_init (PCIBus *bus)
d4d9bf0
 {
d4d9bf0
     pci_create_simple (bus, -1, "AC97");
d4d9bf0
@@ -1404,6 +1414,7 @@ static void ac97_class_init (ObjectClass *klass, void *data)
d4d9bf0
     PCIDeviceClass *k = PCI_DEVICE_CLASS (klass);
d4d9bf0
 
d4d9bf0
     k->realize = ac97_realize;
d4d9bf0
+    k->exit = ac97_exit;
d4d9bf0
     k->vendor_id = PCI_VENDOR_ID_INTEL;
d4d9bf0
     k->device_id = PCI_DEVICE_ID_INTEL_82801AA_5;
d4d9bf0
     k->revision = 0x01;
d4d9bf0
-- 
d4d9bf0
1.7.0.4
d4d9bf0