diff options
Diffstat (limited to 'drivers/kvm/lapic.c')
-rw-r--r-- | drivers/kvm/lapic.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/kvm/lapic.c b/drivers/kvm/lapic.c index 238fcad3cece..8e8dab08be58 100644 --- a/drivers/kvm/lapic.c +++ b/drivers/kvm/lapic.c | |||
@@ -762,19 +762,17 @@ static int apic_mmio_range(struct kvm_io_device *this, gpa_t addr) | |||
762 | return ret; | 762 | return ret; |
763 | } | 763 | } |
764 | 764 | ||
765 | void kvm_free_apic(struct kvm_lapic *apic) | 765 | void kvm_free_lapic(struct kvm_vcpu *vcpu) |
766 | { | 766 | { |
767 | if (!apic) | 767 | if (!vcpu->apic) |
768 | return; | 768 | return; |
769 | 769 | ||
770 | hrtimer_cancel(&apic->timer.dev); | 770 | hrtimer_cancel(&vcpu->apic->timer.dev); |
771 | 771 | ||
772 | if (apic->regs_page) { | 772 | if (vcpu->apic->regs_page) |
773 | __free_page(apic->regs_page); | 773 | __free_page(vcpu->apic->regs_page); |
774 | apic->regs_page = 0; | ||
775 | } | ||
776 | 774 | ||
777 | kfree(apic); | 775 | kfree(vcpu->apic); |
778 | } | 776 | } |
779 | 777 | ||
780 | /* | 778 | /* |
@@ -962,7 +960,7 @@ int kvm_create_lapic(struct kvm_vcpu *vcpu) | |||
962 | if (apic->regs_page == NULL) { | 960 | if (apic->regs_page == NULL) { |
963 | printk(KERN_ERR "malloc apic regs error for vcpu %x\n", | 961 | printk(KERN_ERR "malloc apic regs error for vcpu %x\n", |
964 | vcpu->vcpu_id); | 962 | vcpu->vcpu_id); |
965 | goto nomem; | 963 | goto nomem_free_apic; |
966 | } | 964 | } |
967 | apic->regs = page_address(apic->regs_page); | 965 | apic->regs = page_address(apic->regs_page); |
968 | memset(apic->regs, 0, PAGE_SIZE); | 966 | memset(apic->regs, 0, PAGE_SIZE); |
@@ -980,8 +978,9 @@ int kvm_create_lapic(struct kvm_vcpu *vcpu) | |||
980 | apic->dev.private = apic; | 978 | apic->dev.private = apic; |
981 | 979 | ||
982 | return 0; | 980 | return 0; |
981 | nomem_free_apic: | ||
982 | kfree(apic); | ||
983 | nomem: | 983 | nomem: |
984 | kvm_free_apic(apic); | ||
985 | return -ENOMEM; | 984 | return -ENOMEM; |
986 | } | 985 | } |
987 | EXPORT_SYMBOL_GPL(kvm_create_lapic); | 986 | EXPORT_SYMBOL_GPL(kvm_create_lapic); |