Subject: kern/18234: devsw branch integration breaks device modload
To: None <gnats-bugs@gnats.netbsd.org>
From: Frank Kardel <kardel@acm.org>
List: netbsd-bugs
Date: 09/08/2002 19:50:00
>Number: 18234
>Category: kern
>Synopsis: modload failt with EEXIST
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Sep 08 10:51:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Frank Kardel
>Release: NetBSD 1.6H
>Organization:
>Environment:
System: NetBSD pip 1.6H NetBSD 1.6H (PIP) #4: Sun Sep 8 19:28:24 MEST 2002 kardel@pip:/fs/IC35L060-0-a/src/NetBSD/netbsd/sys/arch/i386/compile/PIP i386
Architecture: i386
Machine: i386
>Description:
modloading a fixed version of xf86 (aperture driver) fails with EEXIST.
>How-To-Repeat:
modload a fixed xf86 module.
>Fix:
See patch below. lkm_offset wasn't set after fixing the allocation
code in cdevsw_attach(). Thus the fix in kern_lkm.c.
Index: sys/kern/kern_lkm.c
===================================================================
RCS file: /src/NetBSD/REPOSITORY/netbsd/sys/kern/kern_lkm.c,v
retrieving revision 1.1.1.2
diff -c -r1.1.1.2 kern_lkm.c
*** sys/kern/kern_lkm.c 2002/09/07 21:01:49 1.1.1.2
--- sys/kern/kern_lkm.c 2002/09/08 17:27:27
***************
*** 744,749 ****
--- 744,753 ----
error = devsw_attach(args->lkm_devname,
args->lkm_bdev, &args->lkm_bdevmaj,
args->lkm_cdev, &args->lkm_cdevmaj);
+ if (error == 0)
+ args->lkm_offset = (args->lkm_bdevmaj == -1) ?
+ args->lkm_cdevmaj :
+ args->lkm_bdevmaj;
break;
case LKM_E_UNLOAD:
Index: sys/kern/subr_devsw.c
===================================================================
RCS file: /src/NetBSD/REPOSITORY/netbsd/sys/kern/subr_devsw.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 subr_devsw.c
*** sys/kern/subr_devsw.c 2002/09/07 21:01:51 1.1.1.1
--- sys/kern/subr_devsw.c 2002/09/08 17:28:20
***************
*** 229,234 ****
--- 229,236 ----
*devmajor = cmajor;
break;
}
+ if (*devmajor < 0)
+ *devmajor = cmajor;
}
if (*devmajor >= MAXDEVSW) {
#ifdef DEVSW_DEBUG
>Release-Note:
>Audit-Trail:
>Unformatted: