diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index dabb60f9072693..92c6f80e6327d8 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -999,7 +999,7 @@ search_memslots(struct kvm_memslots *slots, gfn_t gfn) start = slot + 1; } - if (gfn >= memslots[start].base_gfn && + if (start < slots->used_slots && gfn >= memslots[start].base_gfn && gfn < memslots[start].base_gfn + memslots[start].npages) { atomic_set(&slots->lru_slot, start); return &memslots[start];