Skip to content

Commit

Permalink
KVM: remove redundant assignments in __kvm_set_memory_region
Browse files Browse the repository at this point in the history
__kvm_set_memory_region sets r to EINVAL very early.
Doing it again is not necessary. The same is true later on, where
r is assigned -ENOMEM twice.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Christian Borntraeger authored and Paolo Bonzini committed Sep 5, 2014
1 parent a13f533 commit f2a2516
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions virt/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,6 @@ int __kvm_set_memory_region(struct kvm *kvm,
base_gfn = mem->guest_phys_addr >> PAGE_SHIFT;
npages = mem->memory_size >> PAGE_SHIFT;

r = -EINVAL;
if (npages > KVM_MEM_MAX_NR_PAGES)
goto out;

Expand All @@ -807,7 +806,6 @@ int __kvm_set_memory_region(struct kvm *kvm,
new.npages = npages;
new.flags = mem->flags;

r = -EINVAL;
if (npages) {
if (!old.npages)
change = KVM_MR_CREATE;
Expand Down Expand Up @@ -863,7 +861,6 @@ int __kvm_set_memory_region(struct kvm *kvm,
}

if ((change == KVM_MR_DELETE) || (change == KVM_MR_MOVE)) {
r = -ENOMEM;
slots = kmemdup(kvm->memslots, sizeof(struct kvm_memslots),
GFP_KERNEL);
if (!slots)
Expand Down

0 comments on commit f2a2516

Please sign in to comment.