Module Name: src
Committed By: tsutsui
Date: Fri Dec 11 11:07:05 UTC 2009
Modified Files:
src/sys/dev/ic: mm58167.c
Log Message:
Don't refer garbage in stack.
- An argument of struct timeval *tv passed by todr_gettime(9) is used
for a return value and it doesn't contain valid data. Don't read it.
- Instead, use getmicrotime(9) to get a "reasonable" (i.e. current) time
to see expected year value (which is not kept by this device).
- If current time is not valid, assume this is the first todr_gettime(9)
call from inittodr(9) and use file system time for the "reasonable" year.
Fixes silent hangup after mountroot() on sun2.
XXX: MI todr(9) functions seem to get mangled around year ~22000.
To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/ic/mm58167.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/ic/mm58167.c
diff -u src/sys/dev/ic/mm58167.c:1.11 src/sys/dev/ic/mm58167.c:1.12
--- src/sys/dev/ic/mm58167.c:1.11 Sun Jul 6 13:29:50 2008
+++ src/sys/dev/ic/mm58167.c Fri Dec 11 11:07:04 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: mm58167.c,v 1.11 2008/07/06 13:29:50 tsutsui Exp $ */
+/* $NetBSD: mm58167.c,v 1.12 2009/12/11 11:07:04 tsutsui Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mm58167.c,v 1.11 2008/07/06 13:29:50 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mm58167.c,v 1.12 2009/12/11 11:07:04 tsutsui Exp $");
#include <sys/param.h>
#include <sys/malloc.h>
@@ -84,6 +84,7 @@
struct mm58167_softc *sc = handle->cookie;
struct clock_ymdhms dt_hardware;
struct clock_ymdhms dt_reasonable;
+ struct timeval now;
int s;
uint8_t byte_value;
int leap_year, had_leap_day;
@@ -117,7 +118,16 @@
splx(s);
/* Convert the reasonable time into a date: */
- clock_secs_to_ymdhms(tv->tv_sec, &dt_reasonable);
+ getmicrotime(&now);
+ clock_secs_to_ymdhms(now.tv_sec, &dt_reasonable);
+ if (dt_reasonable.dt_year == POSIX_BASE_YEAR) {
+ /*
+ * Not a reasonable year.
+ * Assume called from inittodr(9) on boot and
+ * use file system time set in inittodr(9).
+ */
+ clock_secs_to_ymdhms(handle->base_time, &dt_reasonable);
+ }
/*
* We need to fake a hardware year. if the hardware MM/DD