Skip to content

Commit

Permalink
KVM: set_memory_region: Don't jump to out_free unnecessarily
Browse files Browse the repository at this point in the history
This makes the separation between the sanity checks and the rest of the
code a bit clearer.

Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
  • Loading branch information
Takuya Yoshikawa authored and Gleb Natapov committed Jan 17, 2013
1 parent a046b81 commit 0ea75e1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions virt/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,9 +778,9 @@ int __kvm_set_memory_region(struct kvm *kvm,
*/
r = -EINVAL;
if (npages && old.npages && npages != old.npages)
goto out_free;
goto out;
if (!npages && !old.npages)
goto out_free;
goto out;

/* Check for overlaps */
r = -EEXIST;
Expand All @@ -789,7 +789,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
continue;
if (!((base_gfn + npages <= slot->base_gfn) ||
(base_gfn >= slot->base_gfn + slot->npages)))
goto out_free;
goto out;
}

/* Free page dirty bitmap if unneeded */
Expand Down Expand Up @@ -890,7 +890,6 @@ int __kvm_set_memory_region(struct kvm *kvm,
kvm_free_physmem_slot(&new, &old);
out:
return r;

}
EXPORT_SYMBOL_GPL(__kvm_set_memory_region);

Expand Down

0 comments on commit 0ea75e1

Please sign in to comment.