diff mbox

KVM: PIT: fix kpit_elapsed division by zero

Message ID 20090702230215.GA25347@amt.cnet (mailing list archive)
State New, archived
Headers show

Commit Message

Marcelo Tosatti July 2, 2009, 11:02 p.m. UTC
Fix division by zero triggered by latch count command on uninitialized
counter.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Avi Kivity July 6, 2009, 7:44 a.m. UTC | #1
On 07/03/2009 02:02 AM, Marcelo Tosatti wrote:
> Fix division by zero triggered by latch count command on uninitialized
> counter.
>    

Applied, thanks.
diff mbox

Patch

diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
index 14bbaae..8c3ac30 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