Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Be robust against an invalid timer period value.



details:   https://anonhg.NetBSD.org/src/rev/cf0fa2ed7355
branches:  trunk
changeset: 747737:cf0fa2ed7355
user:      njoly <njoly%NetBSD.org@localhost>
date:      Wed Sep 30 15:22:11 2009 +0000

description:
Be robust against an invalid timer period value.

diffstat:

 sys/dev/ic/hpet.c |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (29 lines):

diff -r b7e06ccd567c -r cf0fa2ed7355 sys/dev/ic/hpet.c
--- a/sys/dev/ic/hpet.c Wed Sep 30 11:48:22 2009 +0000
+++ b/sys/dev/ic/hpet.c Wed Sep 30 15:22:11 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hpet.c,v 1.7 2009/08/18 17:06:35 dyoung Exp $ */
+/* $NetBSD: hpet.c,v 1.8 2009/09/30 15:22:11 njoly Exp $ */
 
 /*
  * Copyright (c) 2006 Nicolas Joly
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hpet.c,v 1.7 2009/08/18 17:06:35 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hpet.c,v 1.8 2009/09/30 15:22:11 njoly Exp $");
 
 #include <sys/systm.h>
 #include <sys/device.h>
@@ -83,6 +83,10 @@
 
        /* Get frequency */
        val = bus_space_read_4(sc->sc_memt, sc->sc_memh, HPET_PERIOD);
+       if (val == 0) {
+               aprint_error_dev(dv, "invalid timer period\n");
+               return;
+       }
        tc->tc_frequency = 1000000000000000ULL / val;
 
        /* Enable timer */



Home | Main Index | Thread Index | Old Index