Received: from eggs.gnu.org ([140.186.70.92]:40093) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8pRV-0005sp-Dc for qemu-devel@nongnu.org; Wed, 28 Sep 2011 04:24:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R8pRU-0005Se-G6 for qemu-devel@nongnu.org; Wed, 28 Sep 2011 04:24:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15171) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8pRU-0005SV-72 for qemu-devel@nongnu.org; Wed, 28 Sep 2011 04:24:36 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p8S8OYKl015969 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 28 Sep 2011 04:24:34 -0400 From: ajia@redhat.com Date: Wed, 28 Sep 2011 16:24:41 +0800 Message-Id: <1317198281-14922-1-git-send-email-ajia@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH v2] linux-user: fix memory leak in failure path List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alex Jia From: Alex Jia Haven't released memory of 'host_mb' in failure path, and calling malloc allocate memory to 'host_array', however, memory hasn't been freed before the function target_to_host_semarray returns. Signed-off-by: Alex Jia --- linux-user/syscall.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 7735008..22d4fcc 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -2466,6 +2466,7 @@ static inline abi_long target_to_host_semarray(int semid, unsigned short **host_ for(i=0; imtype = tswapl(host_mb->mtype); - free(host_mb); end: + free(host_mb); if (target_mb) unlock_user_struct(target_mb, msgp, 1); return ret; -- 1.7.1