diff options
author | Colin Ian King <colin.king@canonical.com> | 2016-09-19 07:11:59 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-09-20 09:26:30 +0200 |
commit | adad0d02a7d3c958121a4eb9d126015a2353db94 (patch) | |
tree | ff0350eccccf62fb4d4515cc06120f6c825869c2 /arch/x86/kvm/svm.c | |
parent | 095cf55df715d14d5dad75326faf5984e7fc0b3a (diff) | |
download | op-kernel-dev-adad0d02a7d3c958121a4eb9d126015a2353db94.zip op-kernel-dev-adad0d02a7d3c958121a4eb9d126015a2353db94.tar.gz |
kvm: svm: fix unsigned compare less than zero comparison
vm_data->avic_vm_id is a u32, so the check for a error
return (less than zero) such as -EAGAIN from
avic_get_next_vm_id currently has no effect whatsoever.
Fix this by using a temporary int for the comparison
and assign vm_data->avic_vm_id to this. I used an explicit
u32 cast in the assignment to show why vm_data->avic_vm_id
cannot be used in the assign/compare steps.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/svm.c')
-rw-r--r-- | arch/x86/kvm/svm.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 8023d53..9b42214 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1412,7 +1412,7 @@ static void avic_vm_destroy(struct kvm *kvm) static int avic_vm_init(struct kvm *kvm) { unsigned long flags; - int err = -ENOMEM; + int vm_id, err = -ENOMEM; struct kvm_arch *vm_data = &kvm->arch; struct page *p_page; struct page *l_page; @@ -1420,9 +1420,10 @@ static int avic_vm_init(struct kvm *kvm) if (!avic) return 0; - vm_data->avic_vm_id = avic_get_next_vm_id(); - if (vm_data->avic_vm_id < 0) - return vm_data->avic_vm_id; + vm_id = avic_get_next_vm_id(); + if (vm_id < 0) + return vm_id; + vm_data->avic_vm_id = (u32)vm_id; /* Allocating physical APIC ID table (4KB) */ p_page = alloc_page(GFP_KERNEL); |