aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2017-05-31 14:56:37 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2017-06-07 18:22:02 +0200
commitc25a67f0c3d0c86231f9653267a222c4effa706f (patch)
tree086fd41ae8e9c7501863047737b4658810222d6d /hw
parent7e018385103cd7a571b9ea0d6f994af6b1129fe7 (diff)
downloadqemu-c25a67f0c3d0c86231f9653267a222c4effa706f.zip
qemu-c25a67f0c3d0c86231f9653267a222c4effa706f.tar.gz
qemu-c25a67f0c3d0c86231f9653267a222c4effa706f.tar.bz2
edu: fix memory leak on msi_broken platforms
If msi_init fails, the thread has already been created and the mutex/condvar are not destroyed. Initialize everything only after the point where pci_edu_realize cannot fail. Reported-by: Markus Armbruster <armbru@redhat.com> Cc: Peter Xu <peterx@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/misc/edu.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/hw/misc/edu.c b/hw/misc/edu.c
index 401039c..01acacf 100644
--- a/hw/misc/edu.c
+++ b/hw/misc/edu.c
@@ -343,6 +343,12 @@ static void pci_edu_realize(PCIDevice *pdev, Error **errp)
EduState *edu = DO_UPCAST(EduState, pdev, pdev);
uint8_t *pci_conf = pdev->config;
+ pci_config_set_interrupt_pin(pci_conf, 1);
+
+ if (msi_init(pdev, 0, 1, true, false, errp)) {
+ return;
+ }
+
timer_init_ms(&edu->dma_timer, QEMU_CLOCK_VIRTUAL, edu_dma_timer, edu);
qemu_mutex_init(&edu->thr_mutex);
@@ -350,12 +356,6 @@ static void pci_edu_realize(PCIDevice *pdev, Error **errp)
qemu_thread_create(&edu->thread, "edu", edu_fact_thread,
edu, QEMU_THREAD_JOINABLE);
- pci_config_set_interrupt_pin(pci_conf, 1);
-
- if (msi_init(pdev, 0, 1, true, false, errp)) {
- return;
- }
-
memory_region_init_io(&edu->mmio, OBJECT(edu), &edu_mmio_ops, edu,
"edu-mmio", 1 << 20);
pci_register_bar(pdev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &edu->mmio);