]> xenbits.xensource.com Git - xen.git/commitdiff
libxc: fix leak of t_info in xc_tbuf_get_size()
authorHarmandeep Kaur <write.harmandeep@gmail.com>
Fri, 12 Feb 2016 11:08:32 +0000 (16:38 +0530)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 18 Feb 2016 11:42:59 +0000 (11:42 +0000)
Avoid leaking the memory mapping of the trace buffer

Coverity ID 1351228

Signed-off-by: Harmandeep Kaur <write.harmandeep@gmail.com>
Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/libxc/xc_tbuf.c

index 695939a28b27b21fc5f0f067134a4799a97a8b61..283fbd1c8fb898bbbcb978e0fb71ca018504e362 100644 (file)
@@ -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,