aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/kvm_host.h4
-rw-r--r--virt/kvm/kvm_main.c2
2 files changed, 4 insertions, 2 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index fec607537fa3..32fdc45ca35e 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -270,7 +270,7 @@ struct kvm_memory_slot {
270 struct kvm_arch_memory_slot arch; 270 struct kvm_arch_memory_slot arch;
271 unsigned long userspace_addr; 271 unsigned long userspace_addr;
272 u32 flags; 272 u32 flags;
273 int id; 273 short id;
274 bool user_alloc; 274 bool user_alloc;
275}; 275};
276 276
@@ -330,7 +330,7 @@ struct kvm_memslots {
330 u64 generation; 330 u64 generation;
331 struct kvm_memory_slot memslots[KVM_MEM_SLOTS_NUM]; 331 struct kvm_memory_slot memslots[KVM_MEM_SLOTS_NUM];
332 /* The mapping table from slot id to the index in memslots[]. */ 332 /* The mapping table from slot id to the index in memslots[]. */
333 int id_to_index[KVM_MEM_SLOTS_NUM]; 333 short id_to_index[KVM_MEM_SLOTS_NUM];
334}; 334};
335 335
336struct kvm { 336struct kvm {
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 42c1eb73a0e3..bd31096e3698 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -474,6 +474,8 @@ static struct kvm *kvm_create_vm(unsigned long type)
474 INIT_HLIST_HEAD(&kvm->irq_ack_notifier_list); 474 INIT_HLIST_HEAD(&kvm->irq_ack_notifier_list);
475#endif 475#endif
476 476
477 BUILD_BUG_ON(KVM_MEM_SLOTS_NUM > SHRT_MAX);
478
477 r = -ENOMEM; 479 r = -ENOMEM;
478 kvm->memslots = kzalloc(sizeof(struct kvm_memslots), GFP_KERNEL); 480 kvm->memslots = kzalloc(sizeof(struct kvm_memslots), GFP_KERNEL);
479 if (!kvm->memslots) 481 if (!kvm->memslots)