[tip:tools/kvm] kvm tools: arm: don' t crash when no compatible CPU is found

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

 



Commit-ID:  2013c9021220fb1d2e30c698bffc1d8e14c54672
Gitweb:     http://git.kernel.org/tip/2013c9021220fb1d2e30c698bffc1d8e14c54672
Author:     Marc Zyngier <Marc.Zyngier@xxxxxxx>
AuthorDate: Thu, 11 Apr 2013 17:36:22 +0100
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Fri, 12 Apr 2013 09:56:16 +0300

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@xxxxxxx>
Signed-off-by: Will Deacon <will.deacon@xxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/arm/kvm-cpu.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/kvm/arm/kvm-cpu.c b/tools/kvm/arm/kvm-cpu.c
index 7a0eff45..2716690 100644
--- a/tools/kvm/arm/kvm-cpu.c
+++ b/tools/kvm/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)
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux