All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libxenforeignmemory: handle partial failure correctly
@ 2016-02-03 10:10 Ian Campbell
  2016-02-03 10:17 ` Wei Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Campbell @ 2016-02-03 10:10 UTC (permalink / raw)
  To: ian.jackson, wei.liu2, xen-devel; +Cc: 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_free is set, indicating err was
NULL).

CID: 1351219

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
 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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] libxenforeignmemory: handle partial failure correctly
  2016-02-03 10:10 [PATCH] libxenforeignmemory: handle partial failure correctly Ian Campbell
@ 2016-02-03 10:17 ` Wei Liu
  2016-02-03 11:49   ` Ian Campbell
  0 siblings, 1 reply; 3+ messages in thread
From: Wei Liu @ 2016-02-03 10:17 UTC (permalink / raw)
  To: Ian Campbell; +Cc: wei.liu2, ian.jackson, xen-devel

On Wed, Feb 03, 2016 at 10:10:01AM +0000, Ian Campbell wrote:
> 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 | 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
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] libxenforeignmemory: handle partial failure correctly
  2016-02-03 10:17 ` Wei Liu
@ 2016-02-03 11:49   ` Ian Campbell
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Campbell @ 2016-02-03 11:49 UTC (permalink / raw)
  To: Wei Liu; +Cc: ian.jackson, xen-devel

On Wed, 2016-02-03 at 10:17 +0000, Wei Liu wrote:
> On Wed, Feb 03, 2016 at 10:10:01AM +0000, Ian Campbell wrote:
> > 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>

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-02-03 11:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-03 10:10 [PATCH] libxenforeignmemory: handle partial failure correctly Ian Campbell
2016-02-03 10:17 ` Wei Liu
2016-02-03 11:49   ` Ian Campbell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.