mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-06-16 02:15:47 +00:00
kvm tools: arm: don't crash when no compatible CPU is found
If the kernel against which kvm tools was compiled supports more CPU types than kvm tools does, then we can hit a situation where we dereference an empty target slot. Just stepping over empty slots fixes the issue. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
committed by
Will Deacon
parent
6585ffb707
commit
8d0413d2a0
@@ -56,6 +56,8 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
|
||||
|
||||
/* Find an appropriate target CPU type. */
|
||||
for (i = 0; i < ARRAY_SIZE(kvm_arm_targets); ++i) {
|
||||
if (!kvm_arm_targets[i])
|
||||
continue;
|
||||
vcpu_init.target = kvm_arm_targets[i]->id;
|
||||
err = ioctl(vcpu->vcpu_fd, KVM_ARM_VCPU_INIT, &vcpu_init);
|
||||
if (!err)
|
||||
|
||||
Reference in New Issue
Block a user