Re: CAUTION! device megapatch committed.

From: Tor Egge <Tor.Egge_at_cvsup.no.freebsd.org>
Date: Mon, 23 Feb 2004 05:31:57 +0000 (GMT)
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

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
_at__at_ -287,6 +287,7 _at__at_
 
 	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);
_at__at_ -399,7 +400,10 _at__at_
 		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
Received on Sun Feb 22 2004 - 20:32:04 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:44 UTC