summaryrefslogtreecommitdiffstats
path: root/hw/audio
diff options
context:
space:
mode:
authorMarc-André Lureau2016-07-13 02:11:59 +0200
committerMarc-André Lureau2016-09-08 16:05:21 +0200
commite305a16510afa74eec20390479e349402e55ef4c (patch)
treea7b169b1ea91349fb47db68c74e66d635a11e518 /hw/audio
parenttests: fix leak in test-string-input-visitor (diff)
downloadqemu-e305a16510afa74eec20390479e349402e55ef4c.tar.gz
qemu-e305a16510afa74eec20390479e349402e55ef4c.tar.xz
qemu-e305a16510afa74eec20390479e349402e55ef4c.zip
portio: keep references on portio
The isa_register_portio_list() function allocates ioports data/state. Let's keep the reference to this data on some owner. This isn't enough to fix leaks, but at least, ASAN stops complaining of direct leaks. Further cleanup would require calling portio_list_del/destroy(). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/audio')
-rw-r--r--hw/audio/gus.c9
-rw-r--r--hw/audio/sb16.c4
2 files changed, 9 insertions, 4 deletions
diff --git a/hw/audio/gus.c b/hw/audio/gus.c
index 6c02646773..3d08a6576a 100644
--- a/hw/audio/gus.c
+++ b/hw/audio/gus.c
@@ -60,6 +60,8 @@ typedef struct GUSState {
int64_t last_ticks;
qemu_irq pic;
IsaDma *isa_dma;
+ PortioList portio_list1;
+ PortioList portio_list2;
} GUSState;
static uint32_t gus_readb(void *opaque, uint32_t nport)
@@ -265,9 +267,10 @@ static void gus_realizefn (DeviceState *dev, Error **errp)
s->samples = AUD_get_buffer_size_out (s->voice) >> s->shift;
s->mixbuf = g_malloc0 (s->samples << s->shift);
- isa_register_portio_list (d, s->port, gus_portio_list1, s, "gus");
- isa_register_portio_list (d, (s->port + 0x100) & 0xf00,
- gus_portio_list2, s, "gus");
+ isa_register_portio_list(d, &s->portio_list1, s->port,
+ gus_portio_list1, s, "gus");
+ isa_register_portio_list(d, &s->portio_list2, (s->port + 0x100) & 0xf00,
+ gus_portio_list2, s, "gus");
s->isa_dma = isa_get_dma(isa_bus_from_device(d), s->emu.gusdma);
k = ISADMA_GET_CLASS(s->isa_dma);
diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c
index 3a4a57ac31..6b4427f242 100644
--- a/hw/audio/sb16.c
+++ b/hw/audio/sb16.c
@@ -106,6 +106,7 @@ typedef struct SB16State {
/* mixer state */
int mixer_nreg;
uint8_t mixer_regs[256];
+ PortioList portio_list;
} SB16State;
static void SB_audio_callback (void *opaque, int free);
@@ -1378,7 +1379,8 @@ static void sb16_realizefn (DeviceState *dev, Error **errp)
dolog ("warning: Could not create auxiliary timer\n");
}
- isa_register_portio_list (isadev, s->port, sb16_ioport_list, s, "sb16");
+ isa_register_portio_list(isadev, &s->portio_list, s->port,
+ sb16_ioport_list, s, "sb16");
s->isa_hdma = isa_get_dma(isa_bus_from_device(isadev), s->hdma);
k = ISADMA_GET_CLASS(s->isa_hdma);