[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH XEN v6 20/32] tools/libs/foreignmemory: Support err == NULL to map.
On Wed, 2015-12-09 at 12:56 +0000, Wei Liu wrote: > On Wed, Dec 09, 2015 at 12:41:49PM +0000, Ian Campbell wrote: > > On Wed, 2015-12-09 at 12:22 +0000, Wei Liu wrote: > > > > diff --git a/tools/libs/foreignmemory/core.c > > > > b/tools/libs/foreignmemory/core.c > > > > index 21dc7ee..91bea55 100644 > > > > --- a/tools/libs/foreignmemory/core.c > > > > +++ b/tools/libs/foreignmemory/core.c > > > > @@ -14,6 +14,8 @@ > > > > Â */ > > > > Â > > > > Â#include <stdlib.h> > > > > +#include <assert.h> > > > > +#include <errno.h> > > > > Â > > > > Â#include "private.h" > > > > Â > > > > @@ -64,7 +66,33 @@ void > > > > *xenforeignmemory_map(xenforeignmemory_handle > > > > *fmem, > > > > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂuint32_t dom, int prot, > > > > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst xen_pfn_t *arr, int *err, size_t > > > > num) > > > > Â{ > > > > -ÂÂÂÂreturn osdep_xenforeignmemory_map(fmem, dom, prot, arr, err, > > > > num); > > > > +ÂÂÂÂvoid *ret; > > > > +ÂÂÂÂint *err_to_free = NULL; > > > > + > > > > +ÂÂÂÂif ( err == NULL ) > > > > +ÂÂÂÂÂÂÂÂerr = err_to_free = malloc(num * sizeof(int)); > > > > + > > > > > > malloc can fail, which means when user passes in err==NULL there is > > > two > > > possible behaviours of this function? > > > > Partially/Full success and "fail entirely reporting an error" you mean? > > There are always those two possibilities, yes, regardless of err==NULL. > > I > > think that's inline with the doc comment too. > > > > If that's not what you were asking then I'm afraid I don't see what you > > are > > getting at. > > > > What I meant was we should check err != NULL after malloc because > osdep_xenforeignmeory_map dereferences it unconditionally. Ah, I appear to have managed to put that check in "tools/libs/foreignmemory: optimise map(num==1, err==NULL) case" by mistake, so I was confused because I was looking at the final version of the file. I shall move it, thanks. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |