|
[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, 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.
Wei.
> Ian.
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |