diff options
author | Marc Zyngier <Marc.Zyngier@arm.com> | 2013-04-11 17:36:22 +0100 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2015-06-01 16:39:54 +0100 |
commit | 8d0413d2a06c81417a791556829348b657df788f (patch) | |
tree | 9472738bac0a0152c0641fa228fef58fb2d2403d | |
parent | 6585ffb7078a454b383a566c45cf8f538ca1bff0 (diff) | |
download | kvmtool-8d0413d2a06c81417a791556829348b657df788f.tar.gz |
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>
-rw-r--r-- | arm/kvm-cpu.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/arm/kvm-cpu.c b/arm/kvm-cpu.c index 7a0eff45..27166907 100644 --- a/arm/kvm-cpu.c +++ b/arm/kvm-cpu.c @@ -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) |