From 8f11d2a89b3a335acb747ed9d96df7dc2f031834 Mon Sep 17 00:00:00 2001 From: Martin Blapp Date: Thu, 15 May 2003 13:06:57 +0000 Subject: Fix panic if the rtc module gets loaded twice: Make rtc_dev static and destroy the device on cleanup. Submitted by: Orlando Bassotto --- emulators/rtc/files/rtc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'emulators') diff --git a/emulators/rtc/files/rtc.c b/emulators/rtc/files/rtc.c index c9063adc8862..6b604ef6f337 100644 --- a/emulators/rtc/files/rtc.c +++ b/emulators/rtc/files/rtc.c @@ -266,11 +266,12 @@ rtc_poll(dev_t dev, int events, struct proc *p) } /* -=-=-=-=-=-=-=-=-= module load/unload stuff -=-=-=-=-=-=-=-=-= */ +static dev_t rtc_dev = NULL; + static int init_module(void) { int error = 0; - dev_t dev; #if __FreeBSD_version < 500104 error = cdevsw_add(&rtc_cdevsw); @@ -278,8 +279,8 @@ init_module(void) return error; #endif - dev = make_dev(&rtc_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, DEVICE_NAME); - if (dev==NULL) + rtc_dev = make_dev(&rtc_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, DEVICE_NAME); + if (rtc_dev==NULL) error = ENOMEM; return error; @@ -298,6 +299,7 @@ cleanup_module(void) DLog(Lfail, "%p busy", sc); return error; } + destroy_dev(rtc_dev); #if __FreeBSD_version < 500104 error = cdevsw_remove(&rtc_cdevsw); #endif -- cgit v1.2.3