File CVE-2017-5526-qemut-audio-memory-leakage-in-es1370-device.patch of Package xen

Subject: audio: es1370: add exit function
From: Li Qiang liqiang6-s@360.cn Wed Dec 14 18:32:22 2016 -0800
Date: Wed Jan 11 09:19:03 2017 +0100:
Git: 069eb7b2b8fc47c7cb52e5a4af23ea98d939e3da

Currently the es1370 device emulation doesn't have a exit function,
hot unplug this device will leak some memory. Add a exit function to
avoid this.

Signed-off-by: Li Qiang <liqiang6-s@360.cn>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-id: 585200c9.a968ca0a.1ab80.4c98@mx.google.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

Index: xen-4.4.4-testing/tools/qemu-xen-traditional-dir-remote/hw/es1370.c
===================================================================
--- xen-4.4.4-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/es1370.c
+++ xen-4.4.4-testing/tools/qemu-xen-traditional-dir-remote/hw/es1370.c
@@ -1005,6 +1005,21 @@ static void es1370_on_reset (void *opaqu
     es1370_reset (s);
 }
 
+static int es1370_exit(PCIDevice *dev)
+{
+    ES1370State *s = (ES1370State *) dev;
+    int i;
+
+    for (i = 0; i < 2; ++i) {
+        AUD_close_out(&s->card, s->dac_voice[i]);
+    }
+
+    AUD_close_in(&s->card, s->adc_voice);
+    AUD_remove_card(&s->card);
+
+    return 0;
+}
+
 int es1370_init (PCIBus *bus, AudioState *audio)
 {
     PCIES1370State *d;
@@ -1064,5 +1079,6 @@ int es1370_init (PCIBus *bus, AudioState
 
     AUD_register_card (audio, "es1370", &s->card);
     es1370_reset (s);
+    d->dev.unregister = es1370_exit;
     return 0;
 }
openSUSE Build Service is sponsored by