Subject: Re: LKM problem
To: Christian Groessler <cpg@aladdin.de>
From: Quentin Garnier <netbsd-current-users@quatriemek.com>
List: current-users
Date: 02/06/2004 22:00:38
Le 06 Feb 2004 20:39:57 +0100
Christian Groessler a ecrit :
> I'm trying to write a simple LKM.
> Now I have the problem, that when the LKM_E_LOAD command fails, the
> system gets into an inconsistent state.

Indeed.  This is a bug introduced by the behaviour change of rev. 1.29 of
sys/lkm.h.  The following patch should solve it.  I'll commit it later.

Index: lkm.h
===================================================================
RCS file: /cvsroot/src/sys/sys/lkm.h,v
retrieving revision 1.31
diff -u -r1.31 lkm.h
--- lkm.h	2003/11/01 06:50:13	1.31
+++ lkm.h	2004/02/06 20:57:34
@@ -292,7 +292,10 @@
 		lkmtp->private.lkm_any = (void *)&_module;		\
 		if ((error = lkmdispatch(lkmtp, cmd)) != 0)		\
 			return error;					\
-		return load(lkmtp, cmd);				\
+		if ((error = load(lkmtp, cmd)) != 0) {			\
+			(void)lkmdispatch(lkmtp, LKM_E_UNLOAD);		\
+			return error;					\
+		}							\
 		break;							\
 	case LKM_E_UNLOAD:						\
 		if ((error = unload(lkmtp, cmd)) != 0)			\

-- 
Quentin Garnier - cube@cubidou.net - cube@NetBSD.org
"Feels like I'm fiddling while Rome is burning down.
Should I lay my fiddle down and take a rifle from the ground ?"
Leigh Nash/Sixpence None The Richer, Paralyzed, Divine Discontents, 2002.