From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: [PATCH] libxenforeignmemory: handle partial failure correctly Date: Wed, 3 Feb 2016 10:10:01 +0000 Message-ID: <1454494201-14910-1-git-send-email-ian.campbell@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: ian.jackson@eu.citrix.com, wei.liu2@citrix.com, xen-devel@lists.xen.org Cc: Ian Campbell List-Id: xen-devel@lists.xenproject.org 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 --- tools/libs/foreignmemory/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/libs/foreignmemory/core.c b/tools/libs/foreignmemory/core.c index 6591888..a872b95 100644 --- a/tools/libs/foreignmemory/core.c +++ b/tools/libs/foreignmemory/core.c @@ -79,7 +79,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; -- 2.1.4