summaryrefslogtreecommitdiff
path: root/sys/arch/luna88k
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2011-09-13 05:01:22 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2011-09-13 05:01:22 +0000
commit6fbae48bb69bb3c93ca0701289e1ad7286f014ea (patch)
tree4fbe6f3cd36174787afe6525a4e1232e96a27a5a /sys/arch/luna88k
parent0bec1ebc98a41d4d88704037456bed0698dec0c5 (diff)
Do not invoke hardclock() until cpu_initclocks() has been invoked; avoids
a NULL pointer dereference because the softclock interrupt handler cookie is not initialized yet. Found the hard way and fix tested by aoyama@
Diffstat (limited to 'sys/arch/luna88k')
-rw-r--r--sys/arch/luna88k/luna88k/clock.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/arch/luna88k/luna88k/clock.c b/sys/arch/luna88k/luna88k/clock.c
index 1d2f248fbfe..97eb4ab3a02 100644
--- a/sys/arch/luna88k/luna88k/clock.c
+++ b/sys/arch/luna88k/luna88k/clock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clock.c,v 1.6 2006/01/09 21:01:45 miod Exp $ */
+/* $OpenBSD: clock.c,v 1.7 2011/09/13 05:01:21 miod Exp $ */
/* $NetBSD: clock.c,v 1.2 2000/01/11 10:29:35 nisimura Exp $ */
/*
@@ -59,7 +59,7 @@
struct device *clockdev;
const struct clockfns *clockfns;
struct evcount *clockevc;
-int clockinitted;
+int clockinitted, todrvalid;
void
clockattach(dev, fns, evc)
@@ -104,6 +104,8 @@ cpu_initclocks()
#endif
tick = 1000000 / hz; /* number of microseconds between interrupts */
+
+ clockinitted = 1;
}
/*
@@ -140,7 +142,7 @@ inittodr(base)
badbase = 0;
(*clockfns->cf_get)(clockdev, base, &dt);
- clockinitted = 1;
+ todrvalid = 1;
/* simple sanity checks */
if (dt.dt_year < 1970 || dt.dt_mon < 1 || dt.dt_mon > 12
|| dt.dt_day < 1 || dt.dt_day > 31
@@ -189,7 +191,7 @@ resettodr()
{
struct clock_ymdhms dt;
- if (!clockinitted)
+ if (!todrvalid)
return;
clock_secs_to_ymdhms(time.tv_sec, &dt);
(*clockfns->cf_set)(clockdev, &dt);
@@ -207,6 +209,7 @@ clockintr(void *eframe)
clockevc->ec_count++;
*clock_reg[cpu] = 0xffffffff;
- hardclock(eframe);
+ if (clockinitted)
+ hardclock(eframe);
return 1;
}