Re: [PATCH] KVM: loongarch: Add vcpu id check before create vcpu

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 2024/4/12 下午4:47, Wujie Duan wrote:
Add a pre-allocation arch condition to checks that vcpu id should
smaller than max_vcpus

Signed-off-by: Wujie Duan <wjduan@xxxxxxxxxxxxx>
---
  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;
  }
Good catch, and thanks for your contribution.

Reviewed-by: bibo mao <maobibo@xxxxxxxxxxx>





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux