diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index bb29b352ec..3e84960a36 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -93,8 +93,9 @@ bool scrub_free_pages(void); /* Free an allocation, and zero the pointer to it. */ #define FREE_XENHEAP_PAGES(p, o) do { \ - free_xenheap_pages(p, o); \ + void *_ptr_ = (p); \ (p) = NULL; \ + free_xenheap_pages(_ptr_, o); \ } while ( false ) #define FREE_XENHEAP_PAGE(p) FREE_XENHEAP_PAGES(p, 0) diff --git a/xen/include/xen/xmalloc.h b/xen/include/xen/xmalloc.h index 9ecddbff5e..1b88a83be8 100644 --- a/xen/include/xen/xmalloc.h +++ b/xen/include/xen/xmalloc.h @@ -66,9 +66,10 @@ extern void xfree(void *p); /* Free an allocation, and zero the pointer to it. */ -#define XFREE(p) do { \ - xfree(p); \ - (p) = NULL; \ +#define XFREE(p) do { \ + void *_ptr_ = (p); \ + (p) = NULL; \ + xfree(_ptr_); \ } while ( false ) /* Underlying functions */