libxenforeignmemory: handle partial failure correctly
PATCH 1/1 libxenforeignmemory: handle partial failure correctly
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
--- tools/libs/foreignmemory/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libs/foreignmemory/core.c +1 -1
@@ -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;
Signature · 1 line
2.1.4
Quoted 11 lines · Ian Campbell
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_freeis set, indicating err was NULL).CID: 1351219
Signed-off-by Ian Campbell <[email protected]>
Quoted 20 lines
--- tools/libs/foreignmemory/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/libs/foreignmemory/core.c +1
-1@@ -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;Signature · 1 line
2.1.4
Ian Campbell
AppliedQuoted 9 lines · Wei Liu
Quoted 8 lines · Ian Campbell
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_freeis set, indicating err was NULL).
Quoted 5 lines
Quoted 3 lines
CID: 1351219
Signed-off-by Ian Campbell <[email protected]>Acked-by Wei Liu <[email protected]>
Applied, thanks.