From e305a16510afa74eec20390479e349402e55ef4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Wed, 13 Jul 2016 02:11:59 +0200 Subject: portio: keep references on portio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Paolo Bonzini --- hw/audio/gus.c | 9 ++++++--- hw/audio/sb16.c | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'hw/audio') diff --git a/hw/audio/gus.c b/hw/audio/gus.c index 6c02646..3d08a65 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 3a4a57a..6b4427f 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); -- cgit v1.1