aboutsummaryrefslogtreecommitdiffstats
path: root/emulators/rtc
diff options
context:
space:
mode:
authormbr <mbr@FreeBSD.org>2003-05-15 21:06:57 +0800
committermbr <mbr@FreeBSD.org>2003-05-15 21:06:57 +0800
commit498c6465d1f707f682bb55a718b3e371cde820d2 (patch)
tree081722989406c4b180656ae126bda3b10f951d43 /emulators/rtc
parent89b9612a4265b8246ce607d2dc0d492d2b938d6a (diff)
downloadfreebsd-ports-graphics-498c6465d1f707f682bb55a718b3e371cde820d2.tar.gz
freebsd-ports-graphics-498c6465d1f707f682bb55a718b3e371cde820d2.tar.zst
freebsd-ports-graphics-498c6465d1f707f682bb55a718b3e371cde820d2.zip
Fix panic if the rtc module gets loaded twice: Make rtc_dev static
and destroy the device on cleanup. Submitted by: Orlando Bassotto <orlando.bassotto@ieo-research.it>
Diffstat (limited to 'emulators/rtc')
-rw-r--r--emulators/rtc/files/rtc.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/emulators/rtc/files/rtc.c b/emulators/rtc/files/rtc.c
index c9063adc886..6b604ef6f33 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