From mboxrd@z Thu Jan 1 00:00:00 1970 From: Harmandeep Kaur Subject: [PATCH v3] libxc: fix leak of t_info in xc_tbuf_get_size() Date: Fri, 12 Feb 2016 16:38:32 +0530 Message-ID: <1455275312-3515-1-git-send-email-write.harmandeep@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aUBap-0000nD-GA for xen-devel@lists.xenproject.org; Fri, 12 Feb 2016 11:08:55 +0000 Received: by mail-pa0-f65.google.com with SMTP id yy13so3698669pab.1 for ; Fri, 12 Feb 2016 03:08:54 -0800 (PST) List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: wei.liu2@citrix.com, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, dario.faggioli@citrix.com, ian.jackson@eu.citrix.com, Harmandeep Kaur List-Id: xen-devel@lists.xenproject.org Avoid leaking the memory mapping of the trace buffer Coverity ID 1351228 Signed-off-by: Harmandeep Kaur Reviewed-by: Dario Faggioli --- v2: call to unmapping function reduced to one from two v3: passed correct argument sysctl.u.tbuf_op.size in xenforeignmemory_unmap() --- tools/libxc/xc_tbuf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/libxc/xc_tbuf.c b/tools/libxc/xc_tbuf.c index 695939a..283fbd1 100644 --- a/tools/libxc/xc_tbuf.c +++ b/tools/libxc/xc_tbuf.c @@ -70,11 +70,13 @@ int xc_tbuf_get_size(xc_interface *xch, unsigned long *size) sysctl.u.tbuf_op.buffer_mfn); if ( t_info == NULL || t_info->tbuf_size == 0 ) - return -1; + rc = -1; + else + *size = t_info->tbuf_size; - *size = t_info->tbuf_size; + xenforeignmemory_unmap(xch->fmem, t_info, sysctl.u.tbuf_op.size); - return 0; + return rc; } int xc_tbuf_enable(xc_interface *xch, unsigned long pages, unsigned long *mfn, -- 2.5.0