summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGonglei2015-02-27 08:50:14 +0100
committerMichael Tokarev2015-03-10 06:15:34 +0100
commit6c5819c4d685bf5f3c81edb462f4d17fb99ca2b5 (patch)
tree69db5ffef28dff3e0573317f47a0dd59dcac120d
parentsparc/leon3.c: fix memory leak (diff)
downloadqemu-6c5819c4d685bf5f3c81edb462f4d17fb99ca2b5.tar.gz
qemu-6c5819c4d685bf5f3c81edb462f4d17fb99ca2b5.tar.xz
qemu-6c5819c4d685bf5f3c81edb462f4d17fb99ca2b5.zip
macio: fix possible memory leak
If ret = macio_initfn_ide() is less than 0, the timer_memory will leak the memory it points to. Signed-off-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
-rw-r--r--hw/misc/macio/macio.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c
index 9bc3f2d908..063ad80412 100644
--- a/hw/misc/macio/macio.c
+++ b/hw/misc/macio/macio.c
@@ -273,7 +273,7 @@ static int macio_newworld_initfn(PCIDevice *d)
MacIOState *s = MACIO(d);
NewWorldMacIOState *ns = NEWWORLD_MACIO(d);
SysBusDevice *sysbus_dev;
- MemoryRegion *timer_memory = g_new(MemoryRegion, 1);
+ MemoryRegion *timer_memory = NULL;
int i;
int cur_irq = 0;
int ret = macio_common_initfn(d);
@@ -301,6 +301,7 @@ static int macio_newworld_initfn(PCIDevice *d)
}
/* Timer */
+ timer_memory = g_new(MemoryRegion, 1);
memory_region_init_io(timer_memory, OBJECT(s), &timer_ops, NULL, "timer",
0x1000);
memory_region_add_subregion(&s->bar, 0x15000, timer_memory);