Avoid the need to deallocate memory when the data is invalid. It has
the benefit to not fragment memory in Xen.
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
unsigned int start_bus, unsigned int end_bus,
unsigned int seg)
{
- struct hvm_mmcfg *mmcfg, *new = xmalloc(struct hvm_mmcfg);
+ struct hvm_mmcfg *mmcfg, *new;
ASSERT(is_hardware_domain(d));
- if ( !new )
- return -ENOMEM;
-
if ( start_bus > end_bus )
- {
- xfree(new);
return -EINVAL;
- }
+
+ new = xmalloc(struct hvm_mmcfg);
+ if ( !new )
+ return -ENOMEM;
new->addr = addr + (start_bus << 20);
new->start_bus = start_bus;