qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: P J P <ppandit@redhat.com>
To: Qemu Developers <qemu-devel@nongnu.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>,
	Huawei PSIRT <PSIRT@huawei.com>,
	Prasad J Pandit <pjp@fedoraproject.org>
Subject: [Qemu-devel] [PATCH v2] audio: es1370: unregister reset call on exit
Date: Wed, 23 Nov 2016 15:38:55 +0530	[thread overview]
Message-ID: <1479895735-5539-1-git-send-email-ppandit@redhat.com> (raw)

From: Prasad J Pandit <pjp@fedoraproject.org>

ES1370 audio device emulator registers a device reset call with
Qemu during initialisation. But the same is not unregistered when
audio device is unplugged. This leads to a use-after-free error
during reboot, as Qemu resets the machine. Add 'es1370_exit'
PCIDeviceClass method to unregister reset call.

Reported-by: Huawei PSIRT <PSIRT@huawei.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
 hw/audio/es1370.c | 7 +++++++
 1 file changed, 7 insertions(+)

Update: remove space between function name and parenthesis
  -> https://lists.gnu.org/archive/html/qemu-devel/2016-11/msg04257.html

diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c
index 8449b5f..97f6f41 100644
--- a/hw/audio/es1370.c
+++ b/hw/audio/es1370.c
@@ -1047,12 +1047,19 @@ static int es1370_init (PCIBus *bus)
     return 0;
 }
 
+static void es1370_exit(PCIDevice *dev)
+{
+    ES1370State *s = ES1370(dev);
+    qemu_unregister_reset(es1370_on_reset, s);
+}
+
 static void es1370_class_init (ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS (klass);
     PCIDeviceClass *k = PCI_DEVICE_CLASS (klass);
 
     k->realize = es1370_realize;
+    k->exit = es1370_exit;
     k->vendor_id = PCI_VENDOR_ID_ENSONIQ;
     k->device_id = PCI_DEVICE_ID_ENSONIQ_ES1370;
     k->class_id = PCI_CLASS_MULTIMEDIA_AUDIO;
-- 
2.7.4

                 reply	other threads:[~2016-11-23 10:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1479895735-5539-1-git-send-email-ppandit@redhat.com \
    --to=ppandit@redhat.com \
    --cc=PSIRT@huawei.com \
    --cc=kraxel@redhat.com \
    --cc=pjp@fedoraproject.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).