From: Harmandeep Kaur Date: Fri, 12 Feb 2016 11:08:32 +0000 (+0530) Subject: libxc: fix leak of t_info in xc_tbuf_get_size() X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=660308b63e9c483391481c478a1cc730b9ef7d97;p=people%2Fliuw%2Fxen.git libxc: fix leak of t_info in xc_tbuf_get_size() Avoid leaking the memory mapping of the trace buffer Coverity ID 1351228 Signed-off-by: Harmandeep Kaur Reviewed-by: Dario Faggioli Acked-by: Wei Liu --- diff --git a/tools/libxc/xc_tbuf.c b/tools/libxc/xc_tbuf.c index 695939a28b..283fbd1c8f 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,