Any error from hvm_save() or hvm_set_param() leaks the c.data allocation.
Spotted by Coverity.
Fixes: 353744830 "x86/hvm: introduce hvm_copy_context_and_params"
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
return -ENOMEM;
if ( (rc = hvm_save(src, &c)) )
- return rc;
+ goto out;
for ( i = 0; i < HVM_NR_PARAMS; i++ )
{
continue;
if ( (rc = hvm_set_param(dst, i, value)) )
- return rc;
+ goto out;
}
c.cur = 0;
rc = hvm_load(dst, &c);
+
+ out:
vfree(c.data);
return rc;