From: Sean Christopherson Date: Tue, 18 Feb 2020 21:07:17 +0000 (-0800) Subject: KVM: Don't free new memslot if allocation of said memslot fails X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=13f678894bd0112582ea26e9b98db5118150d6a9;p=linux.git KVM: Don't free new memslot if allocation of said memslot fails 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 Reviewed-by: Peter Xu Signed-off-by: Sean Christopherson Signed-off-by: Paolo Bonzini --- diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 6e99525d7dcec..af9eb59e6769b 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -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 */