Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic Don't refer garbage in stack.
details: https://anonhg.NetBSD.org/src/rev/68cdf3a0f8bd
branches: trunk
changeset: 749850:68cdf3a0f8bd
user: tsutsui <tsutsui%NetBSD.org@localhost>
date: Fri Dec 11 11:07:04 2009 +0000
description:
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.
diffstat:
sys/dev/ic/mm58167.c | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diffs (44 lines):
diff -r a5fd975f67d7 -r 68cdf3a0f8bd sys/dev/ic/mm58167.c
--- a/sys/dev/ic/mm58167.c Fri Dec 11 09:04:04 2009 +0000
+++ b/sys/dev/ic/mm58167.c Fri Dec 11 11:07:04 2009 +0000
@@ -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
Home |
Main Index |
Thread Index |
Old Index