summaryrefslogtreecommitdiff
path: root/arch/x86/kvm/cpuid.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kvm/cpuid.c')
-rw-r--r--arch/x86/kvm/cpuid.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 214bcb3a5c1e..1934f5d6b731 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -473,8 +473,12 @@ static struct kvm_cpuid_entry2 *do_host_cpuid(struct kvm_cpuid_array *array,
static int __do_cpuid_func_emulated(struct kvm_cpuid_array *array, u32 func)
{
- struct kvm_cpuid_entry2 *entry = &array->entries[array->nent];
+ struct kvm_cpuid_entry2 *entry;
+
+ if (array->nent >= array->maxnent)
+ return -E2BIG;
+ entry = &array->entries[array->nent];
entry->function = func;
entry->index = 0;
entry->flags = 0;
@@ -511,7 +515,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
r = -E2BIG;
entry = do_host_cpuid(array, function, 0);
- if (WARN_ON(!entry))
+ if (!entry)
goto out;
switch (function) {
@@ -782,9 +786,6 @@ out:
static int do_cpuid_func(struct kvm_cpuid_array *array, u32 func,
unsigned int type)
{
- if (array->nent >= array->maxnent)
- return -E2BIG;
-
if (type == KVM_GET_EMULATED_CPUID)
return __do_cpuid_func_emulated(array, func);