]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
KVM: Don't free new memslot if allocation of said memslot fails
authorSean Christopherson <sean.j.christopherson@intel.com>
Tue, 18 Feb 2020 21:07:17 +0000 (13:07 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 16 Mar 2020 16:57:15 +0000 (17:57 +0100)
The two implementations of kvm_arch_create_memslot() in x86 and PPC are
both good citizens and free up all local resources if creation fails.
Return immediately (via a superfluous goto) instead of calling
kvm_free_memslot().

Note, the call to kvm_free_memslot() is effectively an expensive nop in
this case as there are no resources to be freed.

No functional change intended.

Acked-by: Christoffer Dall <christoffer.dall@arm.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
virt/kvm/kvm_main.c

index 6e99525d7dcec9330a7f20b42afc9115a4d72337..af9eb59e6769bb3533041d19d9dd7f93f445dae1 100644 (file)
@@ -1089,7 +1089,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
                new.userspace_addr = mem->userspace_addr;
 
                if (kvm_arch_create_memslot(kvm, &new, npages))
-                       goto out_free;
+                       goto out;
        }
 
        /* Allocate page dirty bitmap if needed */