From nobody  Thu Oct  3 14:42:33 1996
Received: (from nobody@localhost)
          by freefall.freebsd.org (8.7.5/8.7.3) id OAA27565;
          Thu, 3 Oct 1996 14:42:33 -0700 (PDT)
Message-Id: <199610032142.OAA27565@freefall.freebsd.org>
Date: Thu, 3 Oct 1996 14:42:33 -0700 (PDT)
From: jpt@magic.net
To: freebsd-gnats-submit@freebsd.org
Subject: LKM does not install character devices
X-Send-Pr-Version: www-1.0

>Number:         1716
>Category:       kern
>Synopsis:       LKM does not install character devices
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct  3 14:50:02 PDT 1996
>Closed-Date:    Fri Feb 21 17:20:08 PST 1997
>Last-Modified:  Fri Feb 21 17:20:38 PST 1997
>Originator:     Joseph Thomas
>Release:        FreeBSD-2.2-960801-SNAP
>Organization:
Minnesota Supercomputer Center, Inc.
>Environment:
FreeBSD nevyn.msci.magic.net 2.2-960801-SNAP FreeBSD 2.2-960801-SNAP #4: Thu Oct  3 16:11:05  1996     jpt@nevyn.msci.magic.net:/usr/src/sys/compile/NEVYN  i386	

>Description:
Support was not included for installing character devices into
the cdevsw table via lkm. See sys/kern/kern_lkm.c.

static int
_lkm_dev(lkmtp, cmd)
	struct lkm_table *lkmtp;
	int cmd;
{
	...
	switch(cmd) {
	case LKM_E_LOAD:
		...
		switch(args->lkm_devtype) {
		case LM_DT_BLOCK:
			...
			break;

		case LM_DT_CHAR:
			break;		<<====  Missing insatll code

		default:
			...
		}
	...
	}

	return(err);

}


case LKM_E_UNLOAD: is also incorrect. Value of "descrip" is
only set for LM_DT_BLOCK case but is used for LM_DT_CHAR case.
Descrip should either be set outside of inner case (BLOCK/CHAR)
or should also be set for CHAR case.

>How-To-Repeat:


>Fix:
***************
*** 703,708 ****
--- 703,717 ----
                        break;
  
                case LM_DT_CHAR:
+                       if ( ( i = args->lkm_offset ) == -1 )   /* auto */
+                               descrip = (dev_t) -1;
+                       else
+                               descrip = makedev ( args->lkm_offset, 0 );
+                       if ( err = cdevsw_add ( &descrip, args->lkm_dev.cdev,
+                           &(args->lkm_olddev.cdev) ) ) {
+                               break;
+                       }
+                       args->lkm_offset = major ( descrip );
                        break;
  
                default:
***************
*** 714,724 ****
        case LKM_E_UNLOAD:
                /* current slot... */
                i = args->lkm_offset;
  
                switch(args->lkm_devtype) {
                case LM_DT_BLOCK:
                        /* replace current slot contents with old contents */
-                       descrip = makedev(i,0);
                        bdevsw_add(&descrip, args->lkm_olddev.bdev,NULL);
                        break;
  
--- 723,733 ----
        case LKM_E_UNLOAD:
                /* current slot... */
                i = args->lkm_offset;
+               descrip = makedev(i,0);
  
                switch(args->lkm_devtype) {
                case LM_DT_BLOCK:
                        /* replace current slot contents with old contents */
                        bdevsw_add(&descrip, args->lkm_olddev.bdev,NULL);
                        break;

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: mpp 
State-Changed-When: Fri Feb 21 17:20:08 PST 1997 
State-Changed-Why:  
Suggested patch applied. 
>Unformatted:
