]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/xen.git/commitdiff
libxenforeignmemory: handle partial failure correctly
authorIan Campbell <ian.campbell@citrix.com>
Wed, 3 Feb 2016 10:10:01 +0000 (10:10 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 3 Feb 2016 11:23:08 +0000 (11:23 +0000)
Coverity rightly points out that checking for ret == NULL and then
calling osdep unmap(ret) is wrong.

The intention on this code path is to turn partial failure into total
failure when the err argument is NULL, so we want to take this patch
whenever ret is _non_ NULL (and err_to_free is set, indicating err was
NULL).

CID: 1351219

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/libs/foreignmemory/core.c

index cfb0a7373dff6af9a4d1f4111fd8e8204488871d..a5110a765c70c978c2a8d3da91553b01a5e21506 100644 (file)
@@ -78,7 +78,7 @@ void *xenforeignmemory_map(xenforeignmemory_handle *fmem,
 
     ret = osdep_xenforeignmemory_map(fmem, dom, prot, num, arr, err);
 
-    if ( ret == 0 && err_to_free )
+    if ( ret && err_to_free )
     {
         int i;