CAUTION! device megapatch committed.
Tor Egge
Tor.Egge at cvsup.no.freebsd.org
Sun Feb 22 21:32:04 PST 2004
This caused my laptop to panic during boot until I applied the
enclosed patch. I found two problems:
1. cdevs put on the free list are never removed from that
list even if they are returned from allocdev(). The KASSERT
at line 490 of kern_conf.c triggered when creating a device
for /dev/ad0 due to the structure already having a name (devstat).
2. ugen0 and ums0 were detached during probing of ata0-master.
The major numbers were given back to the system by fini_cdevsw().
When the devices were reattached later during the boot the system
didn't try to allocate a new major number (D_INIT was already set
in the cdevsws, thus no call to prep_cdevsw()) and I got another
panic.
- Tor Egge
-------------- next part --------------
Index: sys/kern/kern_conf.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_conf.c,v
retrieving revision 1.146
diff -u -r1.146 kern_conf.c
--- sys/kern/kern_conf.c 21 Feb 2004 21:57:26 -0000 1.146
+++ sys/kern/kern_conf.c 23 Feb 2004 04:26:58 -0000
@@ -287,6 +287,7 @@
if (LIST_FIRST(&dev_free)) {
si = LIST_FIRST(&dev_free);
+ LIST_REMOVE(si, si_hash); /* XXX: Please add locking here */
} else if (stashed >= DEVT_STASH) {
MALLOC(si, struct cdev *, sizeof(*si), M_DEVT,
M_USE_RESERVE | M_ZERO | M_WAITOK);
@@ -399,7 +400,10 @@
reserved_majors[devsw->d_maj] = 0;
devsw->d_maj = MAJOR_AUTO;
devsw->d_flags &= ~D_ALLOCMAJ;
- }
+ } else if (devsw->d_maj == 0 && (devsw->d_flags & D_INIT) != 0)
+ devsw->d_maj = 256; /* XXX: More tty_cons.c magic */
+ /* Need to call prep_cdevsw() later to allocate new major */
+ devsw->d_flags &= ~D_INIT;
}
static void
More information about the freebsd-current
mailing list