Skip to content

Commit b61e6af

Browse files
lifeixjren1
authored andcommitted
hv: cpuid: don't reference the crossed array
We should consider the boundary condition although we didn't access it. Signed-off-by: Li, Fei1 <fei1.li@intel.com>
1 parent 3fc5ebc commit b61e6af

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

hypervisor/arch/x86/cpuid.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,13 @@ static inline int set_vcpuid_entry(struct vm *vm,
9191
struct vcpuid_entry *tmp;
9292
size_t entry_size = sizeof(struct vcpuid_entry);
9393

94-
tmp = &vm->vcpuid_entries[vm->vcpuid_entry_nr++];
95-
if (vm->vcpuid_entry_nr > MAX_VM_VCPUID_ENTRIES) {
94+
if (vm->vcpuid_entry_nr == MAX_VM_VCPUID_ENTRIES) {
9695
pr_err("%s, vcpuid entry over MAX_VM_VCPUID_ENTRIES(%d)\n",
9796
__func__, MAX_VM_VCPUID_ENTRIES);
9897
return -ENOMEM;
9998
}
99+
100+
tmp = &vm->vcpuid_entries[vm->vcpuid_entry_nr++];
100101
memcpy_s(tmp, entry_size, entry, entry_size);
101102
return 0;
102103
}

0 commit comments

Comments
 (0)