The macro version UNMAP_DOMAIN_PAGE() does both NULL checking and
variable clearing. Move NULL checking into the function itself so that
the semantics is consistent with other similar constructs like XFREE().
This also eases the use unmap_domain_page() in error handling paths,
where we only care about NULL checking but not about variable clearing.
Signed-off-by: Hongyan Xia <hongyxia@amazon.com>
Reviewed-by: Wei Liu <wl@xen.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <jgrall@amazon.com>
lpae_t *map = this_cpu(xen_dommap);
int slot = ((unsigned long) va - DOMHEAP_VIRT_START) >> SECOND_SHIFT;
+ if ( !va )
+ return;
+
local_irq_save(flags);
ASSERT(slot >= 0 && slot < DOMHEAP_ENTRIES);
unsigned long va = (unsigned long)ptr, mfn, flags;
struct vcpu_maphash_entry *hashent;
- if ( va >= DIRECTMAP_VIRT_START )
+ if ( !va || va >= DIRECTMAP_VIRT_START )
return;
ASSERT(va >= MAPCACHE_VIRT_START && va < MAPCACHE_VIRT_END);
#endif /* !CONFIG_DOMAIN_PAGE */
#define UNMAP_DOMAIN_PAGE(p) do { \
- if ( p ) \
- { \
- unmap_domain_page(p); \
- (p) = NULL; \
- } \
+ unmap_domain_page(p); \
+ (p) = NULL; \
} while ( false )
#endif /* __XEN_DOMAIN_PAGE_H__ */