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>
This commit is contained in:
Martin Blapp 2003-05-15 13:06:57 +00:00
parent 6234046b7f
commit 8f11d2a89b
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=81032

View file

@ -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