diff options
author | Marcelo Tosatti <mtosatti@redhat.com> | 2009-07-02 23:02:15 (GMT) |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2009-08-05 10:58:11 (GMT) |
commit | 0ff77873b1318fc2d77a85e70690d3cd6cafbd41 (patch) | |
tree | cb08f8c862a445477aae5a74cb087302336d26e4 | |
parent | e125e7b6944898831b56739a5448e705578bf7e2 (diff) | |
download | linux-0ff77873b1318fc2d77a85e70690d3cd6cafbd41.tar.xz |
KVM: PIT: fix kpit_elapsed division by zero
Fix division by zero triggered by latch count command on uninitialized
counter.
Cc: stable@kernel.org
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r-- | arch/x86/kvm/i8254.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c index 4d6f0d2..21f68e0 100644 --- a/arch/x86/kvm/i8254.c +++ b/arch/x86/kvm/i8254.c @@ -104,6 +104,9 @@ static s64 __kpit_elapsed(struct kvm *kvm) ktime_t remaining; struct kvm_kpit_state *ps = &kvm->arch.vpit->pit_state; + if (!ps->pit_timer.period) + return 0; + /* * The Counter does not stop when it reaches zero. In * Modes 0, 1, 4, and 5 the Counter ``wraps around'' to |