Received: from eggs.gnu.org ([2001:4830:134:3::10]:45277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTypW-0002La-Dw for qemu-devel@nongnu.org; Fri, 06 Mar 2015 15:26:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YTypQ-0003Hw-GG for qemu-devel@nongnu.org; Fri, 06 Mar 2015 15:26:42 -0500 Received: from isrv.corpit.ru ([86.62.121.231]:59898) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTypQ-0003HY-8a for qemu-devel@nongnu.org; Fri, 06 Mar 2015 15:26:36 -0500 From: Michael Tokarev Date: Fri, 6 Mar 2015 23:19:15 +0300 Message-Id: <1425673176-9819-37-git-send-email-mjt@msgid.tls.msk.ru> In-Reply-To: <1425673176-9819-1-git-send-email-mjt@tls.msk.ru> References: <1425673176-9819-1-git-send-email-mjt@tls.msk.ru> Subject: [Qemu-devel] [PATCH 30/51] macio: fix possible memory leak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Aneesh Kumar K.V" Cc: Gonglei , Michael Tokarev , qemu-devel@nongnu.org From: Gonglei If ret = macio_initfn_ide() is less than 0, the timer_memory will leak the memory it points to. Signed-off-by: Gonglei Signed-off-by: Michael Tokarev --- hw/misc/macio/macio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c index e0f1e88..bf96844 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); -- 2.1.4