public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: loongarch: Add vcpu id check before create vcpu
@ 2024-04-12  8:47 Wujie Duan
  2024-04-12  8:58 ` maobibo
  2024-04-12 18:41 ` Sean Christopherson
  0 siblings, 2 replies; 4+ messages in thread
From: Wujie Duan @ 2024-04-12  8:47 UTC (permalink / raw)
  To: zhaotianrui, maobibo, chenhuacai, kernel
  Cc: kvm, loongarch, linux-kernel, Wujie Duan

Add a pre-allocation arch condition to checks that vcpu id should
smaller than max_vcpus

Signed-off-by: Wujie Duan <wjduan@linx-info.com>
---
 arch/loongarch/kvm/vcpu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c
index 3a8779065f73..d41cacf39583 100644
--- a/arch/loongarch/kvm/vcpu.c
+++ b/arch/loongarch/kvm/vcpu.c
@@ -884,6 +884,9 @@ long kvm_arch_vcpu_async_ioctl(struct file *filp,
 
 int kvm_arch_vcpu_precreate(struct kvm *kvm, unsigned int id)
 {
+	if (id >= kvm->max_vcpus)
+		return -EINVAL;
+
 	return 0;
 }
 
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-15  2:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-12  8:47 [PATCH] KVM: loongarch: Add vcpu id check before create vcpu Wujie Duan
2024-04-12  8:58 ` maobibo
2024-04-12 18:41 ` Sean Christopherson
2024-04-15  2:04   ` maobibo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox